mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-22 21:58:12 +08:00
Fix endianness handling in js_dataview_getValue
/ js_dataview_setValue
This commit is contained in:
parent
653b2276cb
commit
3b45d155c7
16
quickjs.c
16
quickjs.c
@ -55157,7 +55157,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
|
|||||||
{
|
{
|
||||||
JSTypedArray *ta;
|
JSTypedArray *ta;
|
||||||
JSArrayBuffer *abuf;
|
JSArrayBuffer *abuf;
|
||||||
int is_swap, size;
|
BOOL littleEndian, is_swap;
|
||||||
|
int size;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
uint64_t pos;
|
uint64_t pos;
|
||||||
@ -55168,9 +55169,8 @@ static JSValue js_dataview_getValue(JSContext *ctx,
|
|||||||
size = 1 << typed_array_size_log2(class_id);
|
size = 1 << typed_array_size_log2(class_id);
|
||||||
if (JS_ToIndex(ctx, &pos, argv[0]))
|
if (JS_ToIndex(ctx, &pos, argv[0]))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
is_swap = TRUE;
|
littleEndian = argc > 1 && JS_ToBool(ctx, argv[1]);
|
||||||
if (argc > 1)
|
is_swap = littleEndian ^ !is_be();
|
||||||
is_swap = !JS_ToBool(ctx, argv[1]);
|
|
||||||
abuf = ta->buffer->u.array_buffer;
|
abuf = ta->buffer->u.array_buffer;
|
||||||
if (abuf->detached)
|
if (abuf->detached)
|
||||||
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
||||||
@ -55255,7 +55255,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
|
|||||||
{
|
{
|
||||||
JSTypedArray *ta;
|
JSTypedArray *ta;
|
||||||
JSArrayBuffer *abuf;
|
JSArrayBuffer *abuf;
|
||||||
int is_swap, size;
|
BOOL littleEndian, is_swap;
|
||||||
|
int size;
|
||||||
uint8_t *ptr;
|
uint8_t *ptr;
|
||||||
uint64_t v64;
|
uint64_t v64;
|
||||||
uint32_t v;
|
uint32_t v;
|
||||||
@ -55294,9 +55295,8 @@ static JSValue js_dataview_setValue(JSContext *ctx,
|
|||||||
v64 = u.u64;
|
v64 = u.u64;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is_swap = TRUE;
|
littleEndian = argc > 2 && JS_ToBool(ctx, argv[2]);
|
||||||
if (argc > 2)
|
is_swap = littleEndian ^ !is_be();
|
||||||
is_swap = !JS_ToBool(ctx, argv[2]);
|
|
||||||
abuf = ta->buffer->u.array_buffer;
|
abuf = ta->buffer->u.array_buffer;
|
||||||
if (abuf->detached)
|
if (abuf->detached)
|
||||||
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
return JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user