WebUI: Add some sanity CHECKs to debug a mystery crash.
We have a mystery crash in the below bug likely due to a nullptr
dereference, or accessing a vector out of bounds.
Adding some sanity CHECKs here to try to track it down.
Bug: 781703
Change-Id: Ieaf1bb0bc815e93b8a7fbe7a548ecd359152b2bd
Reviewed-on: https://chromium-review.googlesource.com/952365
Commit-Queue: Tommy Li <[email protected]>
Reviewed-by: Demetrios Papadopoulos <[email protected]>
Reviewed-by: Peter Kasting <[email protected]>
Cr-Commit-Position: refs/heads/master@{#541298}
diff --git a/components/search_engines/template_url.h b/components/search_engines/template_url.h
index 57b7666..4fa09c5 100644
--- a/components/search_engines/template_url.h
+++ b/components/search_engines/template_url.h
@@ -597,7 +597,11 @@
const std::string& sync_guid() const { return data_.sync_guid; }
const std::vector<TemplateURLRef>& url_refs() const { return url_refs_; }
- const TemplateURLRef& url_ref() const { return url_refs_.back(); }
+ const TemplateURLRef& url_ref() const {
+ // Sanity check for https://crbug.com/781703.
+ CHECK(!url_refs_.empty());
+ return url_refs_.back();
+ }
const TemplateURLRef& suggestions_url_ref() const {
return suggestions_url_ref_;
}