@@ -36892,6 +36892,7 @@ static JSValue JS_InstantiateFunctionListItem2(JSContext *ctx, JSObject *p,
36892
36892
return val;
36893
36893
}
36894
36894
36895
+ /* return -1 if exception, 0 if OK */
36895
36896
static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
36896
36897
JSAtom atom,
36897
36898
const JSCFunctionListEntry *e)
@@ -36934,8 +36935,9 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
36934
36935
/* Function.prototype[Symbol.hasInstance] is not writable nor configurable */
36935
36936
prop_flags = 0;
36936
36937
}
36937
- JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
36938
- (void *)e, prop_flags);
36938
+ if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
36939
+ (void *)e, prop_flags) < 0)
36940
+ return -1;
36939
36941
return 0;
36940
36942
case JS_DEF_CGETSET: /* XXX: use autoinit again ? */
36941
36943
case JS_DEF_CGETSET_MAGIC:
@@ -36949,15 +36951,22 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
36949
36951
getter = JS_NewCFunction2(ctx, e->u.getset.get.generic,
36950
36952
buf, 0, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_getter_magic : JS_CFUNC_getter,
36951
36953
e->magic);
36954
+ if (JS_IsException(getter))
36955
+ return -1;
36952
36956
}
36953
36957
setter = JS_UNDEFINED;
36954
36958
if (e->u.getset.set.generic) {
36955
36959
snprintf(buf, sizeof(buf), "set %s", e->name);
36956
36960
setter = JS_NewCFunction2(ctx, e->u.getset.set.generic,
36957
36961
buf, 1, e->def_type == JS_DEF_CGETSET_MAGIC ? JS_CFUNC_setter_magic : JS_CFUNC_setter,
36958
36962
e->magic);
36963
+ if (JS_IsException(setter)) {
36964
+ JS_FreeValue(ctx, getter);
36965
+ return -1;
36966
+ }
36959
36967
}
36960
- JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags);
36968
+ if (JS_DefinePropertyGetSet(ctx, obj, atom, getter, setter, prop_flags) < 0)
36969
+ return -1;
36961
36970
return 0;
36962
36971
}
36963
36972
break;
@@ -36975,13 +36984,17 @@ static int JS_InstantiateFunctionListItem(JSContext *ctx, JSValueConst obj,
36975
36984
break;
36976
36985
case JS_DEF_PROP_STRING:
36977
36986
case JS_DEF_OBJECT:
36978
- JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
36979
- (void *)e, prop_flags);
36987
+ if (JS_DefineAutoInitProperty(ctx, obj, atom, JS_AUTOINIT_ID_PROP,
36988
+ (void *)e, prop_flags) < 0)
36989
+ return -1;
36980
36990
return 0;
36981
36991
default:
36982
36992
abort();
36983
36993
}
36984
- JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags);
36994
+ if (JS_DefinePropertyValue(ctx, obj, atom, val, prop_flags) < 0) {
36995
+ JS_FreeValue(ctx, val);
36996
+ return -1;
36997
+ }
36985
36998
return 0;
36986
36999
}
36987
37000
0 commit comments