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

Fix global property access crash in raw context #915

Merged
merged 2 commits into from
Feb 14, 2025

Conversation

bnoordhuis
Copy link
Contributor

A raw context doesn't contain anything but that doesn't mean property access is allowed to crash.

Rename interrupt-test.c to the more general api-test.c and add a test.

Fixes: #914

A raw context doesn't contain anything but that doesn't mean property
access is allowed to crash.

Rename interrupt-test.c to the more general api-test.c and add a test.

Fixes: quickjs-ng#914
@bnoordhuis
Copy link
Contributor Author

bnoordhuis commented Feb 14, 2025

It's not a complete fix yet because something like var f = () => {} still crashes because ctx->global_obj is JS_NULL and JS_DefineGlobalFunction and JS_DefineGlobalVar call JS_VALUE_GET_OBJ(ctx->global_obj) without checking it's an object first.

Adding a JS_IsObject check should add only minimal overhead so I'll guess I'll just go and do that? - edit: found a better way, just initialize the global object

@bnoordhuis bnoordhuis merged commit 22cd6ab into quickjs-ng:master Feb 14, 2025
59 checks passed
@bnoordhuis bnoordhuis deleted the fix914 branch February 14, 2025 22:32
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.

JS_NewContextRaw + JS_Eval always segfaults
2 participants