summaryrefslogtreecommitdiff
path: root/quickjs.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-03-27 17:06:26 +0100
committerFabrice Bellard <fabrice@bellard.org>2025-03-27 17:06:26 +0100
commit67de4952540250001ca608ce9a1c42d9aa381e07 (patch)
tree50a0b0c984977ec86d6dd0c2d3dbea80dfb19351 /quickjs.c
parentb0c1a12196e634d74bcf29997cf256ebc89cb6fb (diff)
downloadquickjs-67de4952540250001ca608ce9a1c42d9aa381e07.tar.gz
quickjs-67de4952540250001ca608ce9a1c42d9aa381e07.zip
fixed typed array set operation when obj != receiver
Diffstat (limited to 'quickjs.c')
-rw-r--r--quickjs.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/quickjs.c b/quickjs.c
index b1962de..b656e3b 100644
--- a/quickjs.c
+++ b/quickjs.c
@@ -8757,17 +8757,21 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj,
return -1;
}
typed_array_oob:
- /* must convert the argument even if out of bound access */
- if (p1->class_id == JS_CLASS_BIG_INT64_ARRAY ||
- p1->class_id == JS_CLASS_BIG_UINT64_ARRAY) {
- int64_t v;
- if (JS_ToBigInt64Free(ctx, &v, val))
- return -1;
+ if (p == p1) {
+ /* must convert the argument even if out of bound access */
+ if (p1->class_id == JS_CLASS_BIG_INT64_ARRAY ||
+ p1->class_id == JS_CLASS_BIG_UINT64_ARRAY) {
+ int64_t v;
+ if (JS_ToBigInt64Free(ctx, &v, val))
+ return -1;
+ } else {
+ val = JS_ToNumberFree(ctx, val);
+ JS_FreeValue(ctx, val);
+ if (JS_IsException(val))
+ return -1;
+ }
} else {
- val = JS_ToNumberFree(ctx, val);
JS_FreeValue(ctx, val);
- if (JS_IsException(val))
- return -1;
}
return TRUE;
}