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

Unified Diff: extensions/browser/file_highlighter.cc

Issue 2245143004: Make sure there is no crash on parsing empty manifest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup! Make sure there is no crash on parsing empty manifest Created 4 years, 4 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 | « no previous file | extensions/browser/file_highlighter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/file_highlighter.cc
diff --git a/extensions/browser/file_highlighter.cc b/extensions/browser/file_highlighter.cc
index 2cc669ee2f5f3161cb27348ecbd9caf79da479b8..37ac9d23c8205a63326a504ebc5634e2e6b20d55 100644
--- a/extensions/browser/file_highlighter.cc
+++ b/extensions/browser/file_highlighter.cc
@@ -113,8 +113,10 @@ ManifestHighlighter::ManifestHighlighter(const std::string& manifest,
const std::string& key,
const std::string& specific)
: FileHighlighter(manifest) {
- start_ = contents_.find('{') + 1;
+ start_ = contents_.find('{');
+ start_ = start_ == std::string::npos ? contents_.size() : start_ + 1;
Devlin 2016/08/17 15:14:03 nit: since we reassign start_ in all cases, I thin
Rafał Chłodnicki 2016/08/17 15:54:29 Let me just keep the current version. Proposed sty
end_ = contents_.rfind('}');
+ end_ = end_ == std::string::npos ? contents_.size() : end_;
Parse(key, specific);
}
@@ -125,11 +127,11 @@ ManifestHighlighter::~ManifestHighlighter() {
void ManifestHighlighter::Parse(const std::string& key,
const std::string& specific) {
// First, try to find the bounds of the full key.
- if (FindBounds(key, true) /* enforce at top level */ ) {
+ if (FindBounds(key, true) /* enforce at top level */) {
// If we succeed, and we have a specific location, find the bounds of the
// specific.
if (!specific.empty())
- FindBounds(specific, false /* don't enforce at top level */ );
+ FindBounds(specific, false /* don't enforce at top level */);
// We may have found trailing whitespace. Don't use base::TrimWhitespace,
// because we want to keep any whitespace we find - just not highlight it.
« no previous file with comments | « no previous file | extensions/browser/file_highlighter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698