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

Throw exception on out of memory in dynamic buffer #838

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

bnoordhuis
Copy link
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
61 checks passed
@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