Skip to content

Fix WASM use-after-free by capturing pointers by value - #62

Open
Man1ac-1773 wants to merge 1 commit into
kovzol:masterfrom
Man1ac-1773:fix-wasm-lambda-captures
Open

Fix WASM use-after-free by capturing pointers by value#62
Man1ac-1773 wants to merge 1 commit into
kovzol:masterfrom
Man1ac-1773:fix-wasm-lambda-captures

Conversation

@Man1ac-1773

@Man1ac-1773 Man1ac-1773 commented Jun 18, 2026

Copy link
Copy Markdown

Fixes : #53

Description

On WebAssembly, QFileDialog::getOpenFileContent returns immediately, executing the provided callback asynchronously.

In connector.cpp and auxconnector.cpp, the lambdas passed to this function capture pointer parameters by reference (&open, &gls, &c, &pd, &pm). By the time the async callback is invoked, the enclosing stack frame has been destroyed, resulting in dangling references and undefined behavior.

This patch fixes the issue by capturing these pointers by value. Since the pointed-to objects are long-lived Qt UI models that outlive the file dialog, capturing them by value is both safe and correct.

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