diff options
author | meelapshah@chromium.org <meelapshah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 23:25:15 +0000 |
---|---|---|
committer | meelapshah@chromium.org <meelapshah@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 23:25:15 +0000 |
commit | 26cd5c815ddc94fe643cb7acf23731d2a2d80915 (patch) | |
tree | 013d96cba246839f4d73c7ec1495be47a60db842 /chrome/browser/history/visitsegment_database.cc | |
parent | 54becb736fb020a902393a695142f270f51de1c3 (diff) | |
download | chromium_src-26cd5c815ddc94fe643cb7acf23731d2a2d80915.zip chromium_src-26cd5c815ddc94fe643cb7acf23731d2a2d80915.tar.gz chromium_src-26cd5c815ddc94fe643cb7acf23731d2a2d80915.tar.bz2 |
Fix memory leak in VisitSegmentDatabase::QuerySegmentUsage and HistoryBackend::QueryTopURLsAndRedirects.
BUG=16104
TEST=sh tools/valgrind/chrome_test.sh -t ui --gtest_filter=TabRestoreUITest.RestoreIntoSameWindow
Review URL: http://codereview.chromium.org/160060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21472 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/visitsegment_database.cc')
-rw-r--r-- | chrome/browser/history/visitsegment_database.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/chrome/browser/history/visitsegment_database.cc b/chrome/browser/history/visitsegment_database.cc index 981d43c..cf2cd3c 100644 --- a/chrome/browser/history/visitsegment_database.cc +++ b/chrome/browser/history/visitsegment_database.cc @@ -7,6 +7,7 @@ #include <math.h> #include "base/logging.h" +#include "base/stl_util-inl.h" #include "base/string_util.h" #include "chrome/browser/history/page_usage_data.h" #include "chrome/common/sqlite_compiled_statement.h" @@ -296,8 +297,11 @@ void VisitSegmentDatabase::QuerySegmentUsage( // Limit to the top kResultCount results. sort(results->begin(), results->end(), PageUsageData::Predicate); - if (static_cast<int>(results->size()) > max_result_count) + if (static_cast<int>(results->size()) > max_result_count) { + STLDeleteContainerPointers(results->begin() + max_result_count, + results->end()); results->resize(max_result_count); + } // Now fetch the details about the entries we care about. SQLITE_UNIQUE_STATEMENT(statement2, GetStatementCache(), |