diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-10 17:33:43 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-10 17:33:43 +0000 |
commit | 5549f04ad33f5e19a93913158e88830ef54157ec (patch) | |
tree | f8c13af839b66f17f2efcf678ba583b7279642df /chrome/browser | |
parent | ea4b2f2a7a673609d37b15ddbad773d6f25628de (diff) | |
download | chromium_src-5549f04ad33f5e19a93913158e88830ef54157ec.zip chromium_src-5549f04ad33f5e19a93913158e88830ef54157ec.tar.gz chromium_src-5549f04ad33f5e19a93913158e88830ef54157ec.tar.bz2 |
Changes SessionService to make sure a Pickle is deleted before the
memory the pickle was created from is deleted. I don't think the
current code actually causes a problem as Pickle's destructor won't
attempt to delete the memory in this case, but I'm adding this to make
it clear the Pickle should be deleted and prevent any future problems.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/165241
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/sessions/session_service.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc index 4e6725a..bfed63f 100644 --- a/chrome/browser/sessions/session_service.cc +++ b/chrome/browser/sessions/session_service.cc @@ -1045,11 +1045,16 @@ bool SessionService::ReplacePendingCommand(SessionCommand* command) { if (existing_command->id() == kCommandUpdateTabNavigation) { SessionID::id_type existing_tab_id; int existing_nav_index; - scoped_ptr<Pickle> existing_pickle(existing_command->PayloadAsPickle()); - iterator = NULL; - if (!existing_pickle->ReadInt(&iterator, &existing_tab_id) || - !existing_pickle->ReadInt(&iterator, &existing_nav_index)) { - return false; + { + // Creating a pickle like this means the Pickle references the data from + // the command. Make sure we delete the pickle before the command, else + // the pickle references deleted memory. + scoped_ptr<Pickle> existing_pickle(existing_command->PayloadAsPickle()); + iterator = NULL; + if (!existing_pickle->ReadInt(&iterator, &existing_tab_id) || + !existing_pickle->ReadInt(&iterator, &existing_nav_index)) { + return false; + } } if (existing_tab_id == command_tab_id && existing_nav_index == command_nav_index) { |