@@ -95,11 +95,12 @@ #ifndef HAVE_ASPRINTF static int vasprintf(char **string, const char *format, va_list arguments) { - size_t length, bufferLength = 128; + int length; + size_t bufferLength = 128; *string = NULL; for (;;) { free(*string); @@ -119,11 +120,11 @@ } bufferLength <<= 1; } - if (length != bufferLength - 1) { + if (length > 0 && (size_t)length != bufferLength - 1) { char *resized = realloc(*string, length + 1); /* Ignore if making it smaller failed. */ if (resized != NULL) *string = resized;