From: kasperl@chromium.org Date: Tue, 28 Oct 2008 08:29:23 +0000 (+0000) Subject: Work around issue 131 by checking for empty handles X-Git-Tag: upstream/4.7.83~25100 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e79ebd5ceb22763cceba853417dfffc9856971b0;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/api.cc b/src/api.cc index 2fb568016..86d579be5 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 a78ba32b5..29b786118 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); } }