Skip to content

Fix leak in js_array_buffer_constructor3#514

Closed
bptato wants to merge 1 commit into
bellard:masterfrom
bptato:fix-leak
Closed

Fix leak in js_array_buffer_constructor3#514
bptato wants to merge 1 commit into
bellard:masterfrom
bptato:fix-leak

Conversation

@bptato

@bptato bptato commented May 16, 2026

Copy link
Copy Markdown
Contributor

If alloc_flag is unset, then we are expected to consume the buffer even if we throw an exception. (At least this is what js_array_buffer_transfer seems to assume.)

If alloc_flag is unset, then we are expected to consume the buffer even
if we throw an exception.  (At least this is what js_array_buffer_transfer
seems to assume.)
Comment thread quickjs.c
@@ -56056,13 +56056,15 @@ static JSValue js_array_buffer_constructor3(JSContext *ctx,
if (!alloc_flag && buf && max_len && free_func != js_array_buffer_free) {
// not observable from JS land, only through C API misuse;
// JS code cannot create externally managed buffers directly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, if this is a user error then maybe an assert would suffice?

@bptato

bptato commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Actually, there's a better way to do this. I'll open a new PR.

@bptato bptato closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant