Skip to content

Commit

Permalink
[#17] Fix context properties when value is null.
Browse files Browse the repository at this point in the history
Thanks to Spahl for the report, patch, and test, and general awesomeness
at being so thorough.

[#17 state:resolved]
  • Loading branch information
davisp committed May 25, 2009
1 parent e75f991 commit 888e8cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions THANKS
Expand Up @@ -15,6 +15,7 @@ sk89q
spahl
* Heads up on the signal hack and fix for a compiler warning.
* Bug #16 integer property lookup failure report and fix.
* Bug #17 add_property segfault when value is null.

Mike West
* Reported bug in Context.max_time
Expand Down
2 changes: 1 addition & 1 deletion spidermonkey/context.c
Expand Up @@ -18,7 +18,7 @@ add_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval)
{
JSObject* obj = NULL;

if(!JSVAL_IS_OBJECT(*rval)) return JS_TRUE;
if(JSVAL_IS_NULL(*rval) || !JSVAL_IS_OBJECT(*rval)) return JS_TRUE;

obj = JSVAL_TO_OBJECT(*rval);
if(JS_ObjectIsFunction(jscx, obj)) return set_prop(jscx, jsobj, key, rval);
Expand Down
5 changes: 5 additions & 0 deletions tests/test-context.py
Expand Up @@ -27,6 +27,11 @@ def test_reentry(cx):
cx.execute("var x = 42;")
t.eq(cx.execute("x;"), 42)

@t.cx()
def test_null(cx):
cx.execute("x = null;")
t.eq(cx.execute("x;"), None)

@t.cx()
def test_get_set_limits(cx):
t.eq(cx.max_time(), 0)
Expand Down

0 comments on commit 888e8cb

Please sign in to comment.