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

Unified Diff: src/api.cc

Issue 603393004: String::NewExternal should not crash the renderer. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: comments addressed Created 6 years, 3 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 | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index f1d81ddd5fefa38f3704d11a6c1c7478f97e46c5..bda34bdfacacbb369f5e8db2b18d03c6f38b1ec7 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5483,21 +5483,15 @@ Local<String> v8::String::Concat(Handle<String> left, Handle<String> right) {
}
-static i::Handle<i::String> NewExternalStringHandle(
- i::Isolate* isolate,
- v8::String::ExternalStringResource* resource) {
- // We do not expect this to fail. Change this if it does.
- return isolate->factory()->NewExternalStringFromTwoByte(
- resource).ToHandleChecked();
+static i::MaybeHandle<i::String> NewExternalStringHandle(
+ i::Isolate* isolate, v8::String::ExternalStringResource* resource) {
+ return isolate->factory()->NewExternalStringFromTwoByte(resource);
}
-static i::Handle<i::String> NewExternalOneByteStringHandle(
+static i::MaybeHandle<i::String> NewExternalOneByteStringHandle(
i::Isolate* isolate, v8::String::ExternalOneByteStringResource* resource) {
- // We do not expect this to fail. Change this if it does.
- return isolate->factory()
- ->NewExternalStringFromOneByte(resource)
- .ToHandleChecked();
+ return isolate->factory()->NewExternalStringFromOneByte(resource);
}
@@ -5508,9 +5502,13 @@ Local<String> v8::String::NewExternal(
LOG_API(i_isolate, "String::NewExternal");
ENTER_V8(i_isolate);
CHECK(resource && resource->data());
- i::Handle<i::String> result = NewExternalStringHandle(i_isolate, resource);
- i_isolate->heap()->external_string_table()->AddString(*result);
- return Utils::ToLocal(result);
+ EXCEPTION_PREAMBLE(i_isolate);
+ i::Handle<i::String> string;
+ has_pending_exception =
+ !NewExternalStringHandle(i_isolate, resource).ToHandle(&string);
+ EXCEPTION_BAILOUT_CHECK(i_isolate, Local<String>());
+ i_isolate->heap()->external_string_table()->AddString(*string);
+ return Utils::ToLocal(string);
}
@@ -5546,10 +5544,13 @@ Local<String> v8::String::NewExternal(
LOG_API(i_isolate, "String::NewExternal");
ENTER_V8(i_isolate);
CHECK(resource && resource->data());
- i::Handle<i::String> result =
- NewExternalOneByteStringHandle(i_isolate, resource);
- i_isolate->heap()->external_string_table()->AddString(*result);
- return Utils::ToLocal(result);
+ EXCEPTION_PREAMBLE(i_isolate);
+ i::Handle<i::String> string;
+ has_pending_exception =
+ !NewExternalOneByteStringHandle(i_isolate, resource).ToHandle(&string);
+ EXCEPTION_BAILOUT_CHECK(i_isolate, Local<String>());
+ i_isolate->heap()->external_string_table()->AddString(*string);
+ return Utils::ToLocal(string);
}
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698