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

Unified Diff: runtime/vm/log_test.cc

Issue 911713002: Use printf("%s", str); to avoid glibc assertion (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « runtime/vm/log.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/log_test.cc
diff --git a/runtime/vm/log_test.cc b/runtime/vm/log_test.cc
index b75ccee88c9d8c72e86771dcc2baaa35df744579..eaaa7addff2f6a7fa1f172fd749091fe6899d648 100644
--- a/runtime/vm/log_test.cc
+++ b/runtime/vm/log_test.cc
@@ -17,8 +17,22 @@
namespace dart {
static const char* test_output_;
-static void TestPrinter(const char* print, ...) {
- test_output_ = print;
+static void TestPrinter(const char* format, ...) {
+ // Measure.
+ va_list args;
+ va_start(args, format);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
+ va_end(args);
+
+ // Print string to buffer.
+ char* buffer = reinterpret_cast<char*>(malloc(len + 1));
+ va_list args2;
+ va_start(args2, format);
+ OS::VSNPrint(buffer, (len + 1), format, args2);
+ va_end(args2);
+
+ // Leaks buffer.
+ test_output_ = buffer;
}
class LogTestHelper : public AllStatic {
« no previous file with comments | « runtime/vm/log.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698