From e79ebd5ceb22763cceba853417dfffc9856971b0 Mon Sep 17 00:00:00 2001 From: "kasperl@chromium.org" Date: Tue, 28 Oct 2008 08:29:23 +0000 Subject: [PATCH] Work around issue 131 by checking for empty handles in a few places. Review URL: http://codereview.chromium.org/8828 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@616 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 8 +++++++- src/top.cc | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api.cc b/src/api.cc index 2fb5680169..86d579be5c 100644 --- a/src/api.cc +++ b/src/api.cc @@ -230,7 +230,13 @@ void V8::SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags) { v8::Handle ThrowException(v8::Handle value) { if (IsDeadCheck("v8::ThrowException()")) return v8::Handle(); - i::Top::ScheduleThrow(*Utils::OpenHandle(*value)); + // If we're passed an empty handle, we throw an undefined exception + // to deal more gracefully with out of memory situations. + if (value.IsEmpty()) { + i::Top::ScheduleThrow(i::Heap::undefined_value()); + } else { + i::Top::ScheduleThrow(*Utils::OpenHandle(*value)); + } return v8::Undefined(); } diff --git a/src/top.cc b/src/top.cc index a78ba32b57..29b7861188 100644 --- a/src/top.cc +++ b/src/top.cc @@ -806,7 +806,7 @@ void Top::DoThrow(Object* exception, if (report_exception) { if (message != NULL) { MessageHandler::ReportMessage(message); - } else { + } else if (!message_obj.is_null()) { MessageHandler::ReportMessage(location, message_obj); } }