Index: src/platform-posix.cc |
=================================================================== |
--- src/platform-posix.cc (revision 6074) |
+++ src/platform-posix.cc (working copy) |
@@ -142,6 +142,23 @@ |
} |
+void OS::FPrint(FILE* out, const char* format, ...) { |
+ va_list args; |
+ va_start(args, format); |
+ VFPrint(out, format, args); |
+ va_end(args); |
+} |
+ |
+ |
+void OS::VFPrint(FILE* out, const char* format, va_list args) { |
+#if defined(ANDROID) |
+ LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, format, args); |
+#else |
+ vfprintf(out, format, args); |
+#endif |
+} |
+ |
+ |
void OS::PrintError(const char* format, ...) { |
va_list args; |
va_start(args, format); |
@@ -173,7 +190,9 @@ |
va_list args) { |
int n = vsnprintf(str.start(), str.length(), format, args); |
if (n < 0 || n >= str.length()) { |
- str[str.length() - 1] = '\0'; |
+ // If the length is zero, the assignment fails. |
+ if (str.length() > 0) |
+ str[str.length() - 1] = '\0'; |
return -1; |
} else { |
return n; |