diff --git a/src/api.cc b/src/api.cc index c33365b931..a8ab53723b 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1728,6 +1728,13 @@ Local ScriptCompiler::CompileUnbound( cached_data_mode, i::NOT_NATIVES_CODE); has_pending_exception = result.is_null(); + if (has_pending_exception && cached_data_mode == i::CONSUME_CACHED_DATA) { + // This case won't happen during normal operation; we have compiled + // successfully and produced cached data, and but the second compilation + // of the same source code fails. + delete script_data_impl; + script_data_impl = NULL; + } EXCEPTION_BAILOUT_CHECK(isolate, Local()); raw_result = *result; if ((options & kProduceDataToCache) && script_data_impl != NULL) { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 2ef58fde9d..dc091f3a9c 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -22431,14 +22431,13 @@ void StoringEventLoggerCallback(const char* message, int status) { TEST(EventLogging) { v8::Isolate* isolate = CcTest::isolate(); isolate->SetEventLogger(StoringEventLoggerCallback); - v8::internal::HistogramTimer* histogramTimer = - new v8::internal::HistogramTimer( - "V8.Test", 0, 10000, 50, - reinterpret_cast(isolate)); - histogramTimer->Start(); + v8::internal::HistogramTimer histogramTimer( + "V8.Test", 0, 10000, 50, + reinterpret_cast(isolate)); + histogramTimer.Start(); CHECK_EQ("V8.Test", last_event_message); CHECK_EQ(0, last_event_status); - histogramTimer->Stop(); + histogramTimer.Stop(); CHECK_EQ("V8.Test", last_event_message); CHECK_EQ(1, last_event_status); } diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index 80a116f115..b95944bf0f 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -2009,6 +2009,7 @@ TEST(DontRegressPreParserDataSizes) { data->function_count()); CHECK(false); } + delete data; } }