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

Side by Side Diff: src/objects.cc

Issue 10827072: Fix minor handle unsafety in exception throwing code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 2628 matching lines...) Expand 10 before | Expand all | Expand 10 after
2639 Handle<Object> error = isolate->factory()->NewTypeError( 2639 Handle<Object> error = isolate->factory()->NewTypeError(
2640 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2))); 2640 "no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2)));
2641 return isolate->Throw(*error); 2641 return isolate->Throw(*error);
2642 } 2642 }
2643 2643
2644 2644
2645 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler( 2645 MUST_USE_RESULT MaybeObject* JSProxy::DeletePropertyWithHandler(
2646 String* name_raw, DeleteMode mode) { 2646 String* name_raw, DeleteMode mode) {
2647 Isolate* isolate = GetIsolate(); 2647 Isolate* isolate = GetIsolate();
2648 HandleScope scope(isolate); 2648 HandleScope scope(isolate);
2649 Handle<Object> receiver(this); 2649 Handle<JSProxy> receiver(this);
2650 Handle<Object> name(name_raw); 2650 Handle<Object> name(name_raw);
2651 2651
2652 Handle<Object> args[] = { name }; 2652 Handle<Object> args[] = { name };
2653 Handle<Object> result = CallTrap( 2653 Handle<Object> result = CallTrap(
2654 "delete", Handle<Object>(), ARRAY_SIZE(args), args); 2654 "delete", Handle<Object>(), ARRAY_SIZE(args), args);
2655 if (isolate->has_pending_exception()) return Failure::Exception(); 2655 if (isolate->has_pending_exception()) return Failure::Exception();
2656 2656
2657 Object* bool_result = result->ToBoolean(); 2657 Object* bool_result = result->ToBoolean();
2658 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) { 2658 if (mode == STRICT_DELETION && bool_result == GetHeap()->false_value()) {
2659 Handle<Object> handler(receiver->handler());
2659 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete"); 2660 Handle<String> trap_name = isolate->factory()->LookupAsciiSymbol("delete");
2660 Handle<Object> args[] = { Handle<Object>(handler()), trap_name }; 2661 Handle<Object> args[] = { handler, trap_name };
2661 Handle<Object> error = isolate->factory()->NewTypeError( 2662 Handle<Object> error = isolate->factory()->NewTypeError(
2662 "handler_failed", HandleVector(args, ARRAY_SIZE(args))); 2663 "handler_failed", HandleVector(args, ARRAY_SIZE(args)));
2663 isolate->Throw(*error); 2664 isolate->Throw(*error);
2664 return Failure::Exception(); 2665 return Failure::Exception();
2665 } 2666 }
2666 return bool_result; 2667 return bool_result;
2667 } 2668 }
2668 2669
2669 2670
2670 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler( 2671 MUST_USE_RESULT MaybeObject* JSProxy::DeleteElementWithHandler(
(...skipping 6994 matching lines...) Expand 10 before | Expand all | Expand 10 after
9665 value, 9666 value,
9666 attributes, 9667 attributes,
9667 strict_mode, 9668 strict_mode,
9668 check_prototype, 9669 check_prototype,
9669 set_mode); 9670 set_mode);
9670 } 9671 }
9671 9672
9672 // Don't allow element properties to be redefined for external arrays. 9673 // Don't allow element properties to be redefined for external arrays.
9673 if (HasExternalArrayElements() && set_mode == DEFINE_PROPERTY) { 9674 if (HasExternalArrayElements() && set_mode == DEFINE_PROPERTY) {
9674 Isolate* isolate = GetHeap()->isolate(); 9675 Isolate* isolate = GetHeap()->isolate();
9676 Handle<Object> receiver(this);
9675 Handle<Object> number = isolate->factory()->NewNumberFromUint(index); 9677 Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
9676 Handle<Object> args[] = { Handle<Object>(this), number }; 9678 Handle<Object> args[] = { receiver, number };
9677 Handle<Object> error = isolate->factory()->NewTypeError( 9679 Handle<Object> error = isolate->factory()->NewTypeError(
9678 "redef_external_array_element", HandleVector(args, ARRAY_SIZE(args))); 9680 "redef_external_array_element", HandleVector(args, ARRAY_SIZE(args)));
9679 return isolate->Throw(*error); 9681 return isolate->Throw(*error);
9680 } 9682 }
9681 9683
9682 // Normalize the elements to enable attributes on the property. 9684 // Normalize the elements to enable attributes on the property.
9683 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) { 9685 if ((attributes & (DONT_DELETE | DONT_ENUM | READ_ONLY)) != 0) {
9684 SeededNumberDictionary* dictionary; 9686 SeededNumberDictionary* dictionary;
9685 MaybeObject* maybe_object = NormalizeElements(); 9687 MaybeObject* maybe_object = NormalizeElements();
9686 if (!maybe_object->To(&dictionary)) return maybe_object; 9688 if (!maybe_object->To(&dictionary)) return maybe_object;
(...skipping 3441 matching lines...) Expand 10 before | Expand all | Expand 10 after
13128 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13130 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13129 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13131 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13130 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13132 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13131 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13133 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13132 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13134 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13133 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13135 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13134 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13136 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13135 } 13137 }
13136 13138
13137 } } // namespace v8::internal 13139 } } // 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