Skip to content

Commit d821dae

Browse files
committed
[Backport] Make "key" argument in std::erase_if predicate const.
You're generally not supposed to modify the key in the map while iterating, or removing elements from the map. The standard seem to assume the key passed to predicate is const, but most implementations do not seem to care. In libstdc++ case however this changes with version 31 from GCC 12. Without const qualifier the code fails to compile. Fixes: QTBUG-130707 Bug: 957519 Change-Id: I4b51dcd73c986f8db32653cb3b3a4caaea201752 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5250537 Commit-Queue: Piotr Tworek <piotr.tworek@xperi.com> Reviewed-by: Eric Orth <ericorth@chromium.org> Cr-Commit-Position: refs/heads/main@{#1254963} Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/605801 Reviewed-by: Michael Brüning <michael.bruning@qt.io>
1 parent a7fd4fa commit d821dae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

chromium/net/http/http_auth_cache.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void HttpAuthCache::SetKeyServerEntriesByNetworkAnonymizationKey(
8787

8888
key_server_entries_by_network_anonymization_key_ =
8989
key_server_entries_by_network_anonymization_key;
90-
std::erase_if(entries_, [](EntryMap::value_type& entry_map_pair) {
90+
std::erase_if(entries_, [](const EntryMap::value_type& entry_map_pair) {
9191
return entry_map_pair.first.target == HttpAuth::AUTH_SERVER;
9292
});
9393
}
@@ -311,9 +311,9 @@ void HttpAuthCache::ClearEntriesAddedBetween(
311311
ClearAllEntries();
312312
return;
313313
}
314-
std::erase_if(entries_, [begin_time, end_time,
315-
url_matcher](EntryMap::value_type& entry_map_pair) {
316-
Entry& entry = entry_map_pair.second;
314+
std::erase_if(entries_, [begin_time, end_time, url_matcher](
315+
const EntryMap::value_type& entry_map_pair) {
316+
const Entry& entry = entry_map_pair.second;
317317
return entry.creation_time_ >= begin_time &&
318318
entry.creation_time_ < end_time &&
319319
(url_matcher ? url_matcher.Run(entry.scheme_host_port().GetURL())

0 commit comments

Comments
 (0)