summaryrefslogtreecommitdiffstats
path: root/base/logging.cc
diff options
context:
space:
mode:
authorjoaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 17:02:15 +0000
committerjoaoe@opera.com <joaoe@opera.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-14 17:02:15 +0000
commit5110538a6e595e09e6040c5030d101d97c615124 (patch)
treef96e160cfe58ea513d41ec208e40ca6fe0eb97ec /base/logging.cc
parent8c39f05e2456b727f1df426809a968afd395f58a (diff)
downloadchromium_src-5110538a6e595e09e6040c5030d101d97c615124.zip
chromium_src-5110538a6e595e09e6040c5030d101d97c615124.tar.gz
chromium_src-5110538a6e595e09e6040c5030d101d97c615124.tar.bz2
Make LogMessage() handle strings with null bytes
'LOG(...) << std::string("a\0a", 3);' would cause the line to be truncated, and no newline output. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=257093 Review URL: https://codereview.chromium.org/198103008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257135 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.cc')
-rw-r--r--base/logging.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/base/logging.cc b/base/logging.cc
index de88a86..0e66946 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -597,13 +597,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);
}
@@ -628,7 +628,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
}