summaryrefslogtreecommitdiffstats
path: root/lib/buffer.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:34 +0000
commit1272be04be0cb803eec87f602edb2e3e6f111aea (patch)
treebce17f6478cdd9f3c4ec3d751135dc42786d6a56 /lib/buffer.c
parentReleasing progress-linux version 2.39.3-11~progress7.99u1. (diff)
downloadutil-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.tar.xz
util-linux-1272be04be0cb803eec87f602edb2e3e6f111aea.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.c7
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)