Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: src/runtime.cc

Issue 22859025: Prevent empty handle dereference in Runtime_InternalNumberFormat. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13735 matching lines...) Expand 10 before | Expand all | Expand 10 after
13746 13746
13747 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { 13747 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) {
13748 HandleScope scope(isolate); 13748 HandleScope scope(isolate);
13749 13749
13750 ASSERT(args.length() == 2); 13750 ASSERT(args.length() == 2);
13751 13751
13752 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); 13752 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0);
13753 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); 13753 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1);
13754 13754
13755 bool has_pending_exception = false; 13755 bool has_pending_exception = false;
13756 double value = Execution::ToNumber(number, &has_pending_exception)->Number(); 13756 Handle<Object> value = Execution::ToNumber(number, &has_pending_exception);
13757 if (has_pending_exception) { 13757 if (has_pending_exception) {
13758 ASSERT(isolate->has_pending_exception()); 13758 ASSERT(isolate->has_pending_exception());
13759 return Failure::Exception(); 13759 return Failure::Exception();
13760 } 13760 }
13761 13761
13762 icu::DecimalFormat* number_format = 13762 icu::DecimalFormat* number_format =
13763 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); 13763 NumberFormat::UnpackNumberFormat(isolate, number_format_holder);
13764 if (!number_format) return isolate->ThrowIllegalOperation(); 13764 if (!number_format) return isolate->ThrowIllegalOperation();
13765 13765
13766 icu::UnicodeString result; 13766 icu::UnicodeString result;
13767 number_format->format(value, result); 13767 number_format->format(value->Number(), result);
13768 13768
13769 return *isolate->factory()->NewStringFromTwoByte( 13769 return *isolate->factory()->NewStringFromTwoByte(
13770 Vector<const uint16_t>( 13770 Vector<const uint16_t>(
13771 reinterpret_cast<const uint16_t*>(result.getBuffer()), 13771 reinterpret_cast<const uint16_t*>(result.getBuffer()),
13772 result.length())); 13772 result.length()));
13773 } 13773 }
13774 13774
13775 13775
13776 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { 13776 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) {
13777 HandleScope scope(isolate); 13777 HandleScope scope(isolate);
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
14491 // Handle last resort GC and make sure to allow future allocations 14491 // Handle last resort GC and make sure to allow future allocations
14492 // to grow the heap without causing GCs (if possible). 14492 // to grow the heap without causing GCs (if possible).
14493 isolate->counters()->gc_last_resort_from_js()->Increment(); 14493 isolate->counters()->gc_last_resort_from_js()->Increment();
14494 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 14494 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
14495 "Runtime::PerformGC"); 14495 "Runtime::PerformGC");
14496 } 14496 }
14497 } 14497 }
14498 14498
14499 14499
14500 } } // namespace v8::internal 14500 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698