summaryrefslogtreecommitdiffstats
path: root/chrome/browser/metrics/metrics_service.cc
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:19:18 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-15 22:19:18 +0000
commit9ffcccf40f192a9b172f86203ce5a4e0cff4320c (patch)
treeea1f9191080a968704aad46b99b12d1fb5774a36 /chrome/browser/metrics/metrics_service.cc
parent1a5a71f11012775e56bf78f223ae1fb0f68f5e90 (diff)
downloadchromium_src-9ffcccf40f192a9b172f86203ce5a4e0cff4320c.zip
chromium_src-9ffcccf40f192a9b172f86203ce5a4e0cff4320c.tar.gz
chromium_src-9ffcccf40f192a9b172f86203ce5a4e0cff4320c.tar.bz2
Size the buffer used for the metrics log text properly.
The existing code was abusing the WriteInto interface (base/string_util.h). The size passed to WriteInto should be the size of the string plus one for a terminating NUL byte. This bug caused the final newline in the log to be clipped. c_str users (there probably weren't any) would see the final newline which wouldn't be wouldn't be followed by a NUL byte. TEST=not really any BUG=21733 Review URL: http://codereview.chromium.org/194099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26280 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/metrics/metrics_service.cc')
-rw-r--r--chrome/browser/metrics/metrics_service.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index bd45fb8..f3630f5 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -405,7 +405,7 @@ MetricsService::MetricsService()
server_permits_upload_(true),
state_(INITIALIZED),
pending_log_(NULL),
- pending_log_text_(""),
+ pending_log_text_(),
current_fetch_(NULL),
current_log_(NULL),
idle_since_last_transmission_(false),
@@ -1205,9 +1205,11 @@ void MetricsService::PreparePendingLogText() {
DCHECK(pending_log());
if (!pending_log_text_.empty())
return;
- int original_size = pending_log_->GetEncodedLogSize();
- pending_log_->GetEncodedLog(WriteInto(&pending_log_text_, original_size),
- original_size);
+ int text_size = pending_log_->GetEncodedLogSize();
+
+ // Leave room for the NUL terminator.
+ pending_log_->GetEncodedLog(WriteInto(&pending_log_text_, text_size + 1),
+ text_size);
}
void MetricsService::PrepareFetchWithPendingLog() {