From dc09312ce7d096a5f4ad7ed05925c6bd80d2bc30 Mon Sep 17 00:00:00 2001 From: "Jesuiter, Henry (ALC NetworX GmbH)" Date: Fri, 8 Jul 2016 09:41:16 +0000 Subject: [PATCH] Fix data type for return value of vasprintf() Since size_t is an unsigned data type, it won't evaluate correctly on errors of vasprintf(). This patch makes 'len2' a signed integer, as expected by vasprintf(). 'len2' is of type 'size_t' in util.c:451, but vasprintf in line 457 returns '-1' on error which is checked in line 460. Currently this check will always fail (regardless of the return value of vasprintf()), according to its declaration as unsigned int. [ RC: Added more explanation taken from another list message. ] Signed-off-by: Henry Jesuiter --- util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index e10cedc..594b49f 100644 --- a/util.c +++ b/util.c @@ -448,7 +448,8 @@ void string_append(char **s, const char *str) void string_appendf(char **s, const char *format, ...) { va_list ap; - size_t len1, len2; + size_t len1; + int len2; char *s2; len1 = strlen(*s);