diff options
author | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 07:45:30 +0000 |
---|---|---|
committer | satorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 07:45:30 +0000 |
commit | 38a89d10031f121ebb64ba72e830b48f10a37b0f (patch) | |
tree | e52da862db5ab9611aceff8e6ba5ac57c295bcb5 /net | |
parent | ba7dc540a120f1e3d9f20f138aa1f7f3a467e4a3 (diff) | |
download | chromium_src-38a89d10031f121ebb64ba72e830b48f10a37b0f.zip chromium_src-38a89d10031f121ebb64ba72e830b48f10a37b0f.tar.gz chromium_src-38a89d10031f121ebb64ba72e830b48f10a37b0f.tar.bz2 |
net: Fix a memory leak in upload_data_stream_unittest.cc
The leak was introduced in crrev.com/120946, but the logic
in the test was broken from the beginning. We should not
reuse upload_data_.
BUG=72001
TEST=Run valgrind locally and confirm the leak is gone.
Review URL: https://chromiumcodereview.appspot.com/9348047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/upload_data_stream_unittest.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/base/upload_data_stream_unittest.cc b/net/base/upload_data_stream_unittest.cc index fc1ba69..94ebea5 100644 --- a/net/base/upload_data_stream_unittest.cc +++ b/net/base/upload_data_stream_unittest.cc @@ -109,9 +109,12 @@ void UploadDataStreamTest::FileChangedHelper(const FilePath& file_path, UploadData::Element element; element.SetToFilePathRange(file_path, 1, 2, time); elements.push_back(element); - upload_data_->SetElements(elements); + // Don't use upload_data_ here, as this function is called twice, and + // reusing upload_data_ is wrong. + scoped_refptr<UploadData> upload_data(new UploadData); + upload_data->SetElements(elements); - scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data_)); + scoped_ptr<UploadDataStream> stream(new UploadDataStream(upload_data)); int error_code = stream->Init(); if (error_expected) ASSERT_EQ(ERR_UPLOAD_FILE_CHANGED, error_code); |