Author: [email protected]
Date: Mon Apr 6 07:55:01 2009
New Revision: 1678
Modified:
branches/bleeding_edge/src/objects.cc
branches/bleeding_edge/test/mjsunit/indexed-accessors.js
Log:
Fix crash with indexed setter on objects without corresponding getter.
Review URL: http://codereview.chromium.org/63010
Modified: branches/bleeding_edge/src/objects.cc
==============================================================================
--- branches/bleeding_edge/src/objects.cc (original)
+++ branches/bleeding_edge/src/objects.cc Mon Apr 6 07:55:01 2009
@@ -1,4 +1,4 @@
-// Copyright 2006-2008 the V8 project authors. All rights reserved.
+// Copyright 2006-2009 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -5521,6 +5521,9 @@
if (getter->IsJSFunction()) {
return GetPropertyWithDefinedGetter(receiver,
JSFunction::cast(getter));
+ } else {
+ // Getter is not a function.
+ return Heap::undefined_value();
}
}
return element;
Modified: branches/bleeding_edge/test/mjsunit/indexed-accessors.js
==============================================================================
--- branches/bleeding_edge/test/mjsunit/indexed-accessors.js (original)
+++ branches/bleeding_edge/test/mjsunit/indexed-accessors.js Mon Apr 6
07:55:01 2009
@@ -98,3 +98,23 @@
var q = {};
q.__defineGetter__('0', function() { return 42; });
assertThrows('q[0] = 7');
+
+// Using a getter where only a setter is defined returns undefined.
+var q1 = {};
+q1.__defineSetter__('0', function() {q1.b = 17;});
+assertEquals(q1[0], undefined);
+// Setter works
+q1[0] = 3;
+assertEquals(q1[0], undefined);
+assertEquals(q1.b, 17);
+
+// Complex case of using an undefined getter.
+// From http://code.google.com/p/v8/issues/detail?id=298
+// Reported by nth10sd.
+
+a = function() {};
+__defineSetter__("0", function() {});
+if (a |= '') {};
+assertThrows('this[a].__parent__');
+assertEquals(a, 0);
+assertEquals(this[a], undefined);
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---