Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Unified Diff: runtime/vm/os_win.cc

Issue 10037018: Fix OS::VSNPrint to make it behave similar to linux and macos versions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_win.cc
===================================================================
--- runtime/vm/os_win.cc (revision 6377)
+++ runtime/vm/os_win.cc (working copy)
@@ -161,13 +161,20 @@
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);
Ivan Posva 2012/04/11 07:34:39 You are reusing the args here which is a big NO-NO
siva 2012/04/11 23:12:51 Good point. I have uploaded a CL doing the va_copy
+ }
// Make sure to zero-terminate the string if the output was
// truncated or if there was an error.
- if (written < 0 || written >= size) {
- if (size > 0) {
- str[size - 1] = '\0';
- }
+ if (written >= size) {
+ str[size - 1] = '\0';
}
return written;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698