Chromium Code Reviews| Index: runtime/vm/os_win.cc |
| =================================================================== |
| --- runtime/vm/os_win.cc (revision 6377) |
| +++ runtime/vm/os_win.cc (working copy) |
| @@ -161,10 +161,19 @@ |
| int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { |
| + if (str == NULL || size == 0) { |
| + return _vscprintf(format, args); |
| + } |
| int written =_vsnprintf(str, size, format, args); |
| + if (written < 0) { |
| + // _vsnprintf returns -1 if the number of characters to be written is |
| + // larger than 'size', so we call _vscprintf which returns the number |
| + // of characters that would have been written. |
| + written = _vscprintf(format, args); |
| + } |
| // Make sure to zero-terminate the string if the output was |
| // truncated or if there was an error. |
| - if (written < 0 || written >= size) { |
| + if (written >= size) { |
| if (size > 0) { |
|
hausner
2012/04/10 20:40:04
The size > 0 check is no longer necessary since we
siva
2012/04/10 20:42:25
Done.
|
| str[size - 1] = '\0'; |
| } |