Skip to content

Commit

Permalink
Fix endianness handling in js_dataview_getValue / `js_dataview_setV…
Browse files Browse the repository at this point in the history
…alue`
  • Loading branch information
chqrlie committed Mar 23, 2024
1 parent 653b227 commit 3b45d15
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -55157,7 +55157,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
{
JSTypedArray *ta;
JSArrayBuffer *abuf;
int is_swap, size;
BOOL littleEndian, is_swap;
int size;
uint8_t *ptr;
uint32_t v;
uint64_t pos;
Expand All @@ -55168,9 +55169,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
size = 1 << typed_array_size_log2(class_id);
if (JS_ToIndex(ctx, &pos, argv[0]))
return JS_EXCEPTION;
is_swap = TRUE;
if (argc > 1)
is_swap = !JS_ToBool(ctx, argv[1]);
littleEndian = argc > 1 && JS_ToBool(ctx, argv[1]);
is_swap = littleEndian ^ !is_be();
abuf = ta->buffer->u.array_buffer;
if (abuf->detached)
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
Expand Down Expand Up @@ -55255,7 +55255,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
{
JSTypedArray *ta;
JSArrayBuffer *abuf;
int is_swap, size;
BOOL littleEndian, is_swap;
int size;
uint8_t *ptr;
uint64_t v64;
uint32_t v;
Expand Down Expand Up @@ -55294,9 +55295,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
v64 = u.u64;
}
}
is_swap = TRUE;
if (argc > 2)
is_swap = !JS_ToBool(ctx, argv[2]);
littleEndian = argc > 2 && JS_ToBool(ctx, argv[2]);
is_swap = littleEndian ^ !is_be();
abuf = ta->buffer->u.array_buffer;
if (abuf->detached)
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
Expand Down

0 comments on commit 3b45d15

Please sign in to comment.