Skip to content

Commit

Permalink
Fix misuse of STL in InvalidatorRegistrar
Browse files Browse the repository at this point in the history
The invocation of std::set_intersection() in InvalidatorRegistrar was
using the wrong kind of output iterator, which would lead to crashes
under some conditions (eg. valgrind).  It was technically invalid under
any conditions; we were "lucky" that it didn't crash most of the time.

BUG=304250

Review URL: https://codereview.chromium.org/25855007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227190 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
rlarocque@chromium.org committed Oct 5, 2013
1 parent 456f136 commit 70ae6cd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sync/notifier/invalidator_registrar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "sync/notifier/invalidator_registrar.h"

#include <cstddef>
#include <iterator>
#include <utility>

#include "base/logging.h"
Expand Down Expand Up @@ -45,7 +46,8 @@ void InvalidatorRegistrar::UpdateRegisteredIds(
std::set_intersection(
it->second.begin(), it->second.end(),
ids.begin(), ids.end(),
intersection.begin(), ObjectIdLessThan());
std::inserter(intersection, intersection.end()),
ObjectIdLessThan());
CHECK(intersection.empty())
<< "Duplicate registration: trying to register "
<< ObjectIdToString(*intersection.begin()) << " for "
Expand Down

0 comments on commit 70ae6cd

Please sign in to comment.