mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Bug 700441: Handle null and undefined expressions in for-in statement.
This commit is contained in:
@@ -252,6 +252,14 @@ static js_Iterator *itflatten(js_State *J, js_Object *obj)
|
||||
return iter;
|
||||
}
|
||||
|
||||
js_Object *jsV_emptyiterator(js_State *J)
|
||||
{
|
||||
js_Object *io = jsV_newobject(J, JS_CITERATOR, NULL);
|
||||
io->u.iter.target = NULL;
|
||||
io->u.iter.head = NULL;
|
||||
return io;
|
||||
}
|
||||
|
||||
js_Object *jsV_newiterator(js_State *J, js_Object *obj, int own)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
9
jsrun.c
9
jsrun.c
@@ -1469,11 +1469,12 @@ static void jsR_run(js_State *J, js_Function *F)
|
||||
break;
|
||||
|
||||
case OP_ITERATOR:
|
||||
if (!js_isundefined(J, -1) && !js_isnull(J, -1)) {
|
||||
if (js_isundefined(J, -1) || js_isnull(J, -1))
|
||||
obj = jsV_emptyiterator(J);
|
||||
else
|
||||
obj = jsV_newiterator(J, js_toobject(J, -1), 0);
|
||||
js_pop(J, 1);
|
||||
js_pushobject(J, obj);
|
||||
}
|
||||
js_pop(J, 1);
|
||||
js_pushobject(J, obj);
|
||||
break;
|
||||
|
||||
case OP_NEXTITER:
|
||||
|
||||
@@ -173,6 +173,7 @@ js_Property *jsV_setproperty(js_State *J, js_Object *obj, const char *name);
|
||||
js_Property *jsV_nextproperty(js_State *J, js_Object *obj, const char *name);
|
||||
void jsV_delproperty(js_State *J, js_Object *obj, const char *name);
|
||||
|
||||
js_Object *jsV_emptyiterator(js_State *J);
|
||||
js_Object *jsV_newiterator(js_State *J, js_Object *obj, int own);
|
||||
const char *jsV_nextiterator(js_State *J, js_Object *iter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user