Skip to content

Commit 888e8cb

Browse files
committed
[#17] Fix context properties when value is null.
Thanks to Spahl for the report, patch, and test, and general awesomeness at being so thorough. [#17 state:resolved]
1 parent e75f991 commit 888e8cb

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

THANKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ sk89q
1515
spahl
1616
* Heads up on the signal hack and fix for a compiler warning.
1717
* Bug #16 integer property lookup failure report and fix.
18+
* Bug #17 add_property segfault when value is null.
1819

1920
Mike West
2021
* Reported bug in Context.max_time

spidermonkey/context.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ add_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval)
1818
{
1919
JSObject* obj = NULL;
2020

21-
if(!JSVAL_IS_OBJECT(*rval)) return JS_TRUE;
21+
if(JSVAL_IS_NULL(*rval) || !JSVAL_IS_OBJECT(*rval)) return JS_TRUE;
2222

2323
obj = JSVAL_TO_OBJECT(*rval);
2424
if(JS_ObjectIsFunction(jscx, obj)) return set_prop(jscx, jsobj, key, rval);

tests/test-context.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def test_reentry(cx):
2727
cx.execute("var x = 42;")
2828
t.eq(cx.execute("x;"), 42)
2929

30+
@t.cx()
31+
def test_null(cx):
32+
cx.execute("x = null;")
33+
t.eq(cx.execute("x;"), None)
34+
3035
@t.cx()
3136
def test_get_set_limits(cx):
3237
t.eq(cx.max_time(), 0)

0 commit comments

Comments
 (0)