| Index: src/api.cc
|
| diff --git a/src/api.cc b/src/api.cc
|
| index e9bc470f69f6f33779dbcb30a89e39e2268d8e40..4b0ea5adba48b78aa8cde9349a37144be08d0972 100644
|
| --- a/src/api.cc
|
| +++ b/src/api.cc
|
| @@ -1694,40 +1694,44 @@ Local<UnboundScript> ScriptCompiler::CompileUnbound(
|
| CompileOptions options) {
|
| i::ScriptData* script_data_impl = NULL;
|
| i::CachedDataMode cached_data_mode = i::NO_CACHED_DATA;
|
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
| + ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
|
| + return Local<UnboundScript>());
|
| if (options & kProduceDataToCache) {
|
| cached_data_mode = i::PRODUCE_CACHED_DATA;
|
| ASSERT(source->cached_data == NULL);
|
| if (source->cached_data) {
|
| // Asked to produce cached data even though there is some already -> not
|
| - // good. In release mode, try to do the right thing: Just regenerate the
|
| - // data.
|
| - delete source->cached_data;
|
| - source->cached_data = NULL;
|
| + // good. Fail the compilation.
|
| + EXCEPTION_PREAMBLE(isolate);
|
| + i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(
|
| + "invalid_cached_data", isolate->factory()->NewJSArray(0));
|
| + isolate->Throw(*result);
|
| + isolate->ReportPendingMessages();
|
| + has_pending_exception = true;
|
| + EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
|
| }
|
| } else if (source->cached_data) {
|
| + cached_data_mode = i::CONSUME_CACHED_DATA;
|
| // ScriptData takes care of aligning, in case the data is not aligned
|
| // correctly.
|
| script_data_impl = i::ScriptData::New(
|
| reinterpret_cast<const char*>(source->cached_data->data),
|
| source->cached_data->length);
|
| - // We assert that the pre-data is sane, even though we can actually
|
| - // handle it if it turns out not to be in release mode.
|
| - ASSERT(script_data_impl->SanityCheck());
|
| - if (script_data_impl->SanityCheck()) {
|
| - cached_data_mode = i::CONSUME_CACHED_DATA;
|
| - } else {
|
| - // If the pre-data isn't sane we simply ignore it.
|
| + // If the cached data is not valid, fail the compilation.
|
| + if (script_data_impl == NULL || !script_data_impl->SanityCheck()) {
|
| + EXCEPTION_PREAMBLE(isolate);
|
| + i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(
|
| + "invalid_cached_data", isolate->factory()->NewJSArray(0));
|
| + isolate->Throw(*result);
|
| + isolate->ReportPendingMessages();
|
| delete script_data_impl;
|
| - script_data_impl = NULL;
|
| - delete source->cached_data;
|
| - source->cached_data = NULL;
|
| + has_pending_exception = true;
|
| + EXCEPTION_BAILOUT_CHECK(isolate, Local<UnboundScript>());
|
| }
|
| }
|
|
|
| i::Handle<i::String> str = Utils::OpenHandle(*(source->source_string));
|
| - i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
|
| - ON_BAILOUT(isolate, "v8::ScriptCompiler::CompileUnbound()",
|
| - return Local<UnboundScript>());
|
| LOG_API(isolate, "ScriptCompiler::CompileUnbound");
|
| ENTER_V8(isolate);
|
| i::SharedFunctionInfo* raw_result = NULL;
|
|
|