Skip to content

Throw exception on out of memory in dynamic buffer#838

Merged
bnoordhuis merged 1 commit intoquickjs-ng:masterfrom
bnoordhuis:dbuf-oom-exception
Jan 20, 2025
Merged

Throw exception on out of memory in dynamic buffer#838
bnoordhuis merged 1 commit intoquickjs-ng:masterfrom
bnoordhuis:dbuf-oom-exception

Conversation

@bnoordhuis
Copy link
Copy Markdown
Contributor

js_dbuf_init users that check the return value of functions like dbuf_put should be able to assume that an OOM exception is pending when the function returns an error. No callers currently do so but I am going to start doing that in the not too distant future.

js_dbuf_init takes a JSContext pointer, strongly suggesting it calls js_realloc, but in fact it called js_realloc_rt, which does not raise OOM exceptions.

Call js_realloc and move js_dbuf_realloc closer to js_dbuf_init for legibility reasons.

js_dbuf_init users that check the return value of functions like
dbuf_put should be able to assume that an OOM exception is pending
when the function returns an error. No callers currently do so but
I am going to start doing that in the not too distant future.

js_dbuf_init takes a JSContext pointer, strongly suggesting it calls
js_realloc, but in fact it called js_realloc_rt, which does *not*
raise OOM exceptions.

Call js_realloc and move js_dbuf_realloc closer to js_dbuf_init for
legibility reasons.
@bnoordhuis bnoordhuis merged commit 8132347 into quickjs-ng:master Jan 20, 2025
@bnoordhuis bnoordhuis deleted the dbuf-oom-exception branch January 20, 2025 09:33
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.

2 participants