mirror of
https://github.com/bellard/quickjs.git
synced 2025-11-18 19:40:34 +03:00
added error checking in JS_InstantiateFunctionListItem()
This commit is contained in:
24
quickjs.c
24
quickjs.c
@@ -38858,6 +38858,8 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
JS_FreeAtom(ctx, atom1);
|
JS_FreeAtom(ctx, atom1);
|
||||||
|
if (JS_IsException(val))
|
||||||
|
return -1;
|
||||||
if (atom == JS_ATOM_Symbol_toPrimitive) {
|
if (atom == JS_ATOM_Symbol_toPrimitive) {
|
||||||
/* Symbol.toPrimitive functions are not writable */
|
/* Symbol.toPrimitive functions are not writable */
|
||||||
prop_flags = JS_PROP_CONFIGURABLE;
|
prop_flags = JS_PROP_CONFIGURABLE;
|
||||||
@@ -38875,8 +38877,9 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
/* Function.prototype[Symbol.hasInstance] is not writable nor configurable */
|
/* Function.prototype[Symbol.hasInstance] is not writable nor configurable */
|
||||||
prop_flags = 0;
|
prop_flags = 0;
|
||||||
}
|
}
|
||||||
JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
||||||
(void *)e, prop_flags);
|
(void *)e, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
case JS_DEF_CGETSET: /* XXX: use autoinit again ? */
|
case JS_DEF_CGETSET: /* XXX: use autoinit again ? */
|
||||||
case JS_DEF_CGETSET_MAGIC:
|
case JS_DEF_CGETSET_MAGIC:
|
||||||
@@ -38890,6 +38893,8 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
getter = JS_NewCFunction2(ctx, e->u.getset.get.generic,
|
getter = JS_NewCFunction2(ctx, e->u.getset.get.generic,
|
||||||
buf, 0, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_getter_magic : JS_CFUNC_getter,
|
buf, 0, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_getter_magic : JS_CFUNC_getter,
|
||||||
e->magic);
|
e->magic);
|
||||||
|
if (JS_IsException(getter))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
setter = JS_UNDEFINED;
|
setter = JS_UNDEFINED;
|
||||||
if (e->u.getset.set.generic) {
|
if (e->u.getset.set.generic) {
|
||||||
@@ -38897,8 +38902,13 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
setter = JS_NewCFunction2(ctx, e->u.getset.set.generic,
|
setter = JS_NewCFunction2(ctx, e->u.getset.set.generic,
|
||||||
buf, 1, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_setter_magic : JS_CFUNC_setter,
|
buf, 1, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_setter_magic : JS_CFUNC_setter,
|
||||||
e->magic);
|
e->magic);
|
||||||
|
if (JS_IsException(setter)) {
|
||||||
|
JS_FreeValue(ctx, getter);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags);
|
}
|
||||||
|
if (JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -38922,13 +38932,15 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
|
|||||||
break;
|
break;
|
||||||
case JS_DEF_PROP_STRING:
|
case JS_DEF_PROP_STRING:
|
||||||
case JS_DEF_OBJECT:
|
case JS_DEF_OBJECT:
|
||||||
JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
|
||||||
(void *)e, prop_flags);
|
(void *)e, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags);
|
if (JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags) < 0)
|
||||||
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user