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 <henry.jesuiter@alcnetworx.de>
master
Jesuiter, Henry (ALC NetworX GmbH) 2016-07-08 09:41:16 +00:00 committed by Richard Cochran
parent 3938cbc101
commit dc09312ce7
1 changed files with 2 additions and 1 deletions

3
util.c
View File

@ -448,7 +448,8 @@ void string_append(char **s, const char *str)
void string_appendf(char **s, const char *format, ...) void string_appendf(char **s, const char *format, ...)
{ {
va_list ap; va_list ap;
size_t len1, len2; size_t len1;
int len2;
char *s2; char *s2;
len1 = strlen(*s); len1 = strlen(*s);