Skip to content

Fix leak in js_array_buffer_constructor3#514

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

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

Conversation

@bptato
Copy link
Copy Markdown
Contributor

@bptato bptato commented May 16, 2026

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?

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