]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/buffer: fix buffer reset
authorKarel Zak <kzak@redhat.com>
Mon, 9 Aug 2021 09:07:17 +0000 (11:07 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Aug 2021 09:07:17 +0000 (11:07 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/buffer.c

index b63b3684a97f19fde6870bb2541500e94adeb6d3..4cd9fcf65c68957eee2378df1c7222b310120c74 100644 (file)
@@ -12,7 +12,9 @@ void ul_buffer_reset_data(struct ul_buffer *buf)
        if (buf->begin)
                buf->begin[0] = '\0';
        buf->end = buf->begin;
-       memset(buf->ptrs, 0, buf->nptrs * sizeof(char *));
+
+       if (buf->ptrs && buf->nptrs)
+               memset(buf->ptrs, 0, buf->nptrs * sizeof(char *));
 }
 
 void ul_buffer_free_data(struct ul_buffer *buf)