Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1440)

Unified Diff: ui/gfx/image/image.cc

Issue 1773433002: Fix use-after-free in gfx::Image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/image/image.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/image/image.cc
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index 9b59496a0a87b2b32ff18ecd6875eec22c103554..86cc83a31d48e50ad9bc29a21af2a296a278b09d 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -752,7 +752,12 @@ internal::ImageRep* Image::GetRepresentation(
void Image::AddRepresentation(scoped_ptr<internal::ImageRep> rep) const {
CHECK(storage_.get());
RepresentationType type = rep->type();
- storage_->representations().insert(std::make_pair(type, std::move(rep)));
+ auto result =
+ storage_->representations().insert(std::make_pair(type, std::move(rep)));
+
+ // insert should not fail (implies that there was already a representation of
+ // that type in the map).
+ CHECK(result.second) << "type was already in map.";
}
} // namespace gfx
« no previous file with comments | « ui/gfx/image/image.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698