@@ -11867,7 +11867,7 @@ static int js_unary_arith_bigint(JSContext *ctx,
11867
11867
return -1;
11868
11868
}
11869
11869
r = JS_GetBigInt(res);
11870
- a = JS_ToBigInt (ctx, &a_s, op1);
11870
+ a = JS_ToBigIntFree (ctx, &a_s, op1); // infallible, always a bigint
11871
11871
ret = 0;
11872
11872
switch(op) {
11873
11873
case OP_inc:
@@ -11890,7 +11890,6 @@ static int js_unary_arith_bigint(JSContext *ctx,
11890
11890
abort();
11891
11891
}
11892
11892
JS_FreeBigInt(ctx, a, &a_s);
11893
- JS_FreeValue(ctx, op1);
11894
11893
if (unlikely(ret)) {
11895
11894
JS_FreeValue(ctx, res);
11896
11895
throw_bf_exception(ctx, ret);
@@ -12023,16 +12022,21 @@ static int js_binary_arith_bigint(JSContext *ctx, OPCodeEnum op,
12023
12022
int ret;
12024
12023
JSValue res;
12025
12024
12026
- res = JS_NewBigInt(ctx);
12027
- if (JS_IsException(res))
12028
- goto fail;
12029
- a = JS_ToBigInt(ctx, &a_s, op1);
12030
- if (!a)
12031
- goto fail;
12032
- b = JS_ToBigInt(ctx, &b_s, op2);
12025
+ a = JS_ToBigIntFree(ctx, &a_s, op1);
12026
+ if (!a) {
12027
+ JS_FreeValue(ctx, op2);
12028
+ return -1;
12029
+ }
12030
+ b = JS_ToBigIntFree(ctx, &b_s, op2);
12033
12031
if (!b) {
12034
12032
JS_FreeBigInt(ctx, a, &a_s);
12035
- goto fail;
12033
+ return -1;
12034
+ }
12035
+ res = JS_NewBigInt(ctx);
12036
+ if (JS_IsException(res)) {
12037
+ JS_FreeBigInt(ctx, a, &a_s);
12038
+ JS_FreeBigInt(ctx, b, &b_s);
12039
+ return -1;
12036
12040
}
12037
12041
r = JS_GetBigInt(res);
12038
12042
ret = 0;
@@ -12103,20 +12107,13 @@ static int js_binary_arith_bigint(JSContext *ctx, OPCodeEnum op,
12103
12107
}
12104
12108
JS_FreeBigInt(ctx, a, &a_s);
12105
12109
JS_FreeBigInt(ctx, b, &b_s);
12106
- JS_FreeValue(ctx, op1);
12107
- JS_FreeValue(ctx, op2);
12108
12110
if (unlikely(ret)) {
12109
12111
JS_FreeValue(ctx, res);
12110
12112
throw_bf_exception(ctx, ret);
12111
12113
return -1;
12112
12114
}
12113
12115
*pres = JS_CompactBigInt(ctx, res);
12114
12116
return 0;
12115
- fail:
12116
- JS_FreeValue(ctx, res);
12117
- JS_FreeValue(ctx, op1);
12118
- JS_FreeValue(ctx, op2);
12119
- return -1;
12120
12117
}
12121
12118
12122
12119
static no_inline __exception int js_binary_arith_slow(JSContext *ctx, JSValue *sp,
0 commit comments