mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 798873 Patch 3 - flex_string fix for Windows vsnprintf r=jesup
This commit is contained in:
parent
dd2bac76ff
commit
be98e21abb
@ -178,6 +178,14 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
|
||||
vsnprintf_result = vsnprintf(fs->buffer + fs->string_length, fs->buffer_length - fs->string_length, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
/* Special case just for Windows where vsnprintf is broken
|
||||
and returns -1 if buffer too large unless you size it 0. */
|
||||
if (vsnprintf_result < 0) {
|
||||
va_start(ap, format);
|
||||
vsnprintf_result = vsnprintf(NULL, 0, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
if (fs->string_length + vsnprintf_result >= fs->buffer_length) {
|
||||
/* Buffer overflow, resize */
|
||||
flex_string_check_alloc(fs, fs->string_length + vsnprintf_result + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user