wpp: Properly use va_start/va_end around vsnprintf().

oldstable
Nikolay Sivov 2012-02-18 14:06:36 +03:00 committed by Alexandre Julliard
parent 945e16c281
commit fdcf7cc9af
1 changed files with 3 additions and 1 deletions

View File

@ -329,6 +329,7 @@ void pp_writestring(const char *format, ...)
va_start(valist, format); va_start(valist, format);
len = vsnprintf(buffer, buffercapacity, len = vsnprintf(buffer, buffercapacity,
format, valist); format, valist);
va_end(valist);
/* If the string is longer than buffersize, vsnprintf returns /* If the string is longer than buffersize, vsnprintf returns
* the string length with glibc >= 2.1, -1 with glibc < 2.1 */ * the string length with glibc >= 2.1, -1 with glibc < 2.1 */
while(len > buffercapacity || len < 0) while(len > buffercapacity || len < 0)
@ -345,10 +346,11 @@ void pp_writestring(const char *format, ...)
return; return;
} }
buffer = new_buffer; buffer = new_buffer;
va_start(valist, format);
len = vsnprintf(buffer, buffercapacity, len = vsnprintf(buffer, buffercapacity,
format, valist); format, valist);
va_end(valist);
} }
va_end(valist);
wpp_callbacks->write(buffer, len); wpp_callbacks->write(buffer, len);
} }