Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve JS_GetArrayBuffer #361

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
@@ -53214,7 +53214,8 @@ static JSArrayBuffer *js_get_array_buffer(JSContext *ctx, JSValueConst obj)
}

/* return NULL if exception. WARNING: any JS call can detach the
buffer and render the returned pointer invalid */
buffer and render the returned pointer invalid. psize can be
NULL. */
uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj)
{
JSArrayBuffer *abuf = js_get_array_buffer(ctx, obj);
@@ -53224,10 +53225,14 @@ uint8_t *JS_GetArrayBuffer(JSContext *ctx, size_t *psize, JSValueConst obj)
JS_ThrowTypeErrorDetachedArrayBuffer(ctx);
goto fail;
}
*psize = abuf->byte_length;
if (psize) {
*psize = abuf->byte_length;
}
return abuf->data;
fail:
*psize = 0;
if (psize) {
*psize = 0;
}
return NULL;
}