From 071f7fdfc123916de491b299424a8e95e4634a7b Mon Sep 17 00:00:00 2001 From: "yangguo@chromium.org" Date: Tue, 14 Aug 2012 12:16:38 +0000 Subject: [PATCH] Do checks when receiving external string resources through the API. This is to find incorrect API usage. R=ulan@chromium.org BUG=140050 Review URL: https://chromiumcodereview.appspot.com/10836236 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12308 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/api.cc b/src/api.cc index f3f5b16..f152175 100644 --- a/src/api.cc +++ b/src/api.cc @@ -4790,6 +4790,7 @@ Local v8::String::NewExternal( EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); LOG_API(isolate, "String::NewExternal"); ENTER_V8(isolate); + CHECK(resource && resource->data()); i::Handle result = NewExternalStringHandle(isolate, resource); isolate->heap()->external_string_table()->AddString(*result); return Utils::ToLocal(result); @@ -4810,6 +4811,7 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { if (isolate->heap()->IsInGCPostProcessing()) { return false; } + CHECK(resource && resource->data()); bool result = obj->MakeExternal(resource); if (result && !obj->IsSymbol()) { isolate->heap()->external_string_table()->AddString(*obj); @@ -4824,6 +4826,7 @@ Local v8::String::NewExternal( EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); LOG_API(isolate, "String::NewExternal"); ENTER_V8(isolate); + CHECK(resource && resource->data()); i::Handle result = NewExternalAsciiStringHandle(isolate, resource); isolate->heap()->external_string_table()->AddString(*result); return Utils::ToLocal(result); @@ -4845,6 +4848,7 @@ bool v8::String::MakeExternal( if (isolate->heap()->IsInGCPostProcessing()) { return false; } + CHECK(resource && resource->data()); bool result = obj->MakeExternal(resource); if (result && !obj->IsSymbol()) { isolate->heap()->external_string_table()->AddString(*obj); -- 2.7.4