diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2025-03-27 17:06:26 +0100 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2025-03-27 17:06:26 +0100 |
commit | 67de4952540250001ca608ce9a1c42d9aa381e07 (patch) | |
tree | 50a0b0c984977ec86d6dd0c2d3dbea80dfb19351 /quickjs.c | |
parent | b0c1a12196e634d74bcf29997cf256ebc89cb6fb (diff) | |
download | quickjs-67de4952540250001ca608ce9a1c42d9aa381e07.tar.gz quickjs-67de4952540250001ca608ce9a1c42d9aa381e07.zip |
fixed typed array set operation when obj != receiver
Diffstat (limited to 'quickjs.c')
-rw-r--r-- | quickjs.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -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; } |