Skip to content

Fix potential leak in JSValue assignment#7814

Open
eddyashton wants to merge 2 commits intomicrosoft:mainfrom
eddyashton:js_wrapped_value_assignment_leak
Open

Fix potential leak in JSValue assignment#7814
eddyashton wants to merge 2 commits intomicrosoft:mainfrom
eddyashton:js_wrapped_value_assignment_leak

Conversation

@eddyashton
Copy link
Copy Markdown
Member

No description provided.

@eddyashton eddyashton requested a review from a team as a code owner April 10, 2026 14:58
Copilot AI review requested due to automatic review settings April 10, 2026 14:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a potential memory leak in the QuickJS JSValue wrapper by ensuring previously-held values are released during copy-assignment, and adds a unit test to validate ref-count behavior.

Changes:

  • Free the currently-held JSValue in JSWrappedValue::operator=(const JSWrappedValue&) before duplicating the new value.
  • Add a doctest that checks QuickJS ref-counts decrease/increase as expected across copy-assignment and destruction.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/js/core/wrapped_value.cpp Fixes JSWrappedValue copy-assignment to release the old value before overwriting it.
src/js/test/js.cpp Adds a regression test asserting correct QuickJS ref-count behavior for copy-assignment.

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.

3 participants