diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:33:32 +0000 |
commit | 8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch) | |
tree | 1fdda006866bca20d41cb206767ea5241e36852f /lib/buffer.c | |
parent | Adding debian version 2.39.3-11. (diff) | |
download | util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip |
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/buffer.c')
-rw-r--r-- | lib/buffer.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/buffer.c b/lib/buffer.c index fda2fc8..cc863fa 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -11,7 +11,7 @@ void ul_buffer_reset_data(struct ul_buffer *buf) { if (buf->begin) - buf->begin[0] = '\0'; + memset(buf->begin, 0, buf->sz); buf->end = buf->begin; if (buf->ptrs && buf->nptrs) @@ -49,7 +49,7 @@ int ul_buffer_is_empty(struct ul_buffer *buf) int ul_buffer_save_pointer(struct ul_buffer *buf, unsigned short ptr_idx) { if (ptr_idx >= buf->nptrs) { - char **tmp = realloc(buf->ptrs, (ptr_idx + 1) * sizeof(char *)); + char **tmp = reallocarray(buf->ptrs, ptr_idx + 1, sizeof(char *)); if (!tmp) return -EINVAL; @@ -134,12 +134,11 @@ int ul_buffer_append_data(struct ul_buffer *buf, const char *data, size_t sz) if (!buf) return -EINVAL; - if (!data || !*data) + if (!data) return 0; if (buf->begin && buf->end) maxsz = buf->sz - (buf->end - buf->begin); - if (maxsz <= sz + 1) { int rc = ul_buffer_alloc_data(buf, buf->sz + sz + 1); if (rc) |