summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-15 03:03:30 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-15 03:03:30 +0000
commit9504f194280791e04b468ecb518e175305757c5f (patch)
tree7f3411d03213e38048c91bd7c15fc5ee1f642f17 /chrome
parent4ff391fcc5b88061912f73ec570f389100cc5e2a (diff)
downloadchromium_src-9504f194280791e04b468ecb518e175305757c5f.zip
chromium_src-9504f194280791e04b468ecb518e175305757c5f.tar.gz
chromium_src-9504f194280791e04b468ecb518e175305757c5f.tar.bz2
Fix erase method usage on STL containers in Chrome. Invoking erase on the iterator renders it invalid. We were continuing to use this iterator.
R=darin Review URL: http://codereview.chromium.org/10925 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc9
-rw-r--r--chrome/browser/resource_dispatcher_host.cc2
-rw-r--r--chrome/browser/resource_dispatcher_host.h5
-rw-r--r--chrome/views/tabbed_pane.cc3
4 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index 61b4b5b..719ebcc 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -195,11 +195,13 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<std::wstring>& xml_files,
std::map<std::wstring, TemplateURL*> search_engine_for_url;
std::string content;
+ bool need_to_increment_iter;
// The first XML file represents the default search engine in Firefox 3, so we
// need to keep it on top of the list.
TemplateURL* default_turl = NULL;
for (std::vector<std::wstring>::const_iterator iter = xml_files.begin();
- iter != xml_files.end(); ++iter) {
+ iter != xml_files.end();) {
+ need_to_increment_iter = true;
file_util::ReadFileToString(*iter, &content);
TemplateURL* template_url = new TemplateURL();
FirefoxURLParameterFilter param_filter;
@@ -216,7 +218,8 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<std::wstring>& xml_files,
// returns a vector with first Firefox default search engines and then
// the user's ones. We want to give priority to the user ones.
delete iter->second;
- search_engine_for_url.erase(iter);
+ iter = search_engine_for_url.erase(iter);
+ need_to_increment_iter = false;
}
// Give this a keyword to facilitate tab-to-search, if possible.
template_url->set_keyword(TemplateURLModel::GenerateKeyword(GURL(url),
@@ -229,6 +232,8 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<std::wstring>& xml_files,
delete template_url;
}
content.clear();
+ if (need_to_increment_iter)
+ ++iter;
}
// Put the results in the |search_engines| vector.
diff --git a/chrome/browser/resource_dispatcher_host.cc b/chrome/browser/resource_dispatcher_host.cc
index fdaadc3..6f1aba3 100644
--- a/chrome/browser/resource_dispatcher_host.cc
+++ b/chrome/browser/resource_dispatcher_host.cc
@@ -1923,7 +1923,7 @@ void ResourceDispatcherHost::RemovePendingRequest(int render_process_host_id,
}
void ResourceDispatcherHost::RemovePendingRequest(
- PendingRequestList::iterator& iter) {
+ const PendingRequestList::iterator& iter) {
// Notify the login handler that this request object is going away.
ExtraRequestInfo* info = ExtraInfoForRequest(iter->second);
if (info && info->login_handler)
diff --git a/chrome/browser/resource_dispatcher_host.h b/chrome/browser/resource_dispatcher_host.h
index 3207965..fc21c7e 100644
--- a/chrome/browser/resource_dispatcher_host.h
+++ b/chrome/browser/resource_dispatcher_host.h
@@ -414,7 +414,10 @@ class ResourceDispatcherHost : public URLRequest::Delegate {
const std::string& content_disposition);
void RemovePendingRequest(int render_process_host_id, int request_id);
- void RemovePendingRequest(PendingRequestList::iterator& iter);
+ // Deletes the pending request identified by the iterator passed in.
+ // This function will invalidate the iterator passed in. Callers should
+ // not rely on this iterator being valid on return.
+ void RemovePendingRequest(const PendingRequestList::iterator& iter);
// Notify our observers that we started receiving a response for a request.
void NotifyResponseStarted(URLRequest* request, int render_process_host_id);
diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc
index bab0d72..9fe72a7 100644
--- a/chrome/views/tabbed_pane.cc
+++ b/chrome/views/tabbed_pane.cc
@@ -120,9 +120,10 @@ View* TabbedPane::RemoveTabAtIndex(int index) {
ResizeContents(tab_control_);
std::vector<View*>::iterator iter = tab_views_.begin() + index;
+ View* removed_tab = *iter;
tab_views_.erase(iter);
- return *iter;
+ return removed_tab;
}
void TabbedPane::SelectTabAt(int index) {