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

Unified Diff: Source/bindings/v8/ScriptRegexp.cpp

Issue 300103002: ScriptRegexp::match(): gracefully fail if regexp.exec() throws. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 | « LayoutTests/fast/js/script-tests/regexp-match-exception.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptRegexp.cpp
diff --git a/Source/bindings/v8/ScriptRegexp.cpp b/Source/bindings/v8/ScriptRegexp.cpp
index 5f951caee1f54ba5774d657355545f4cc85485f1..98eccc8b5c93cceb86335382b6a041a74d77c1db 100644
--- a/Source/bindings/v8/ScriptRegexp.cpp
+++ b/Source/bindings/v8/ScriptRegexp.cpp
@@ -80,6 +80,9 @@ int ScriptRegexp::match(const String& string, int startFrom, int* matchLength) c
v8::Handle<v8::Value> argv[] = { v8String(isolate, string.substring(startFrom)) };
v8::Local<v8::Value> returnValue = V8ScriptRunner::callInternalFunction(exec, regex, WTF_ARRAY_LENGTH(argv), argv, isolate);
+ if (tryCatch.HasCaught())
+ return -1;
+
// RegExp#exec returns null if there's no match, otherwise it returns an
// Array of strings with the first being the whole match string and others
// being subgroups. The Array also has some random properties tacked on like
@@ -87,6 +90,7 @@ int ScriptRegexp::match(const String& string, int startFrom, int* matchLength) c
//
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp/exec
+ ASSERT(!returnValue.IsEmpty());
if (!returnValue->IsArray())
return -1;
« no previous file with comments | « LayoutTests/fast/js/script-tests/regexp-match-exception.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698