If buf->bytes, buf->used, and len are all 0, buf_grow() will do nothing,
and memcpy() willbe called with a NULL first argument. This will cause
an error because the function is annotated with __nonnull(1, 2).
Fixes: e62d8c7 ("strbuf: make strbuf_pushchars() a little less dumb")
Signed-off-by: Martin Wilck <martin_wilck@gmx.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/257
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
assert(src != NULL);
assert(buf != NULL);
+ if (sz == 0)
+ return 0;
+
if (!strbuf_reserve_extra(buf, sz))
return 0;
return 0;
}
-DEFINE_TEST(test_strbuf_pushmem, .description = "test strbuf_reserve",
- .expected_fail = true);
+DEFINE_TEST(test_strbuf_pushmem, .description = "test strbuf_reserve");
static int test_strbuf_used(const struct test *t)
{