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

Unified Diff: base/logging.cc

Issue 198103008: Make LogMessage() handle strings with null bytes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ignoring the return value Created 6 years, 9 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: base/logging.cc
diff --git a/base/logging.cc b/base/logging.cc
index c4366d839c0c134e6f442585b698b9c4f22fb1c1..ed6b69ba7c6c134b85bc4db928ad5da2b637ad5a 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -609,13 +609,13 @@ LogMessage::~LogMessage() {
}
__android_log_write(priority, "chromium", str_newline.c_str());
#endif
- fprintf(stderr, "%s", str_newline.c_str());
+ ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr));
fflush(stderr);
} else if (severity_ >= kAlwaysPrintErrorLevel) {
// When we're only outputting to a log file, above a certain log level, we
// should still output to stderr so that we can better detect and diagnose
// problems with unit tests, especially on the buildbots.
- fprintf(stderr, "%s", str_newline.c_str());
+ ignore_result(fwrite(str_newline.data(), str_newline.size(), 1, stderr));
fflush(stderr);
}
@@ -640,7 +640,8 @@ LogMessage::~LogMessage() {
&num_written,
NULL);
#else
- fprintf(log_file, "%s", str_newline.c_str());
+ ignore_result(fwrite(
+ str_newline.data(), str_newline.size(), 1, log_file));
fflush(log_file);
#endif
}
« 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