Skip to content

Fix memory leak in Function::get_script_origin#1902

Open
goffrie wants to merge 1 commit intodenoland:mainfrom
goffrie:get-script-origin
Open

Fix memory leak in Function::get_script_origin#1902
goffrie wants to merge 1 commit intodenoland:mainfrom
goffrie:get-script-origin

Conversation

@goffrie
Copy link
Contributor

@goffrie goffrie commented Jan 21, 2026

Previously v8__Function__GetScriptOrigin returned a newly allocated object from the C++ heap, then the caller never freed it.
Return it by-value instead.
I believe a handle scope is also required, as Function::GetScriptOrigin internally creates Local handles.

}

int v8__ScriptOrigin__ScriptId(const v8::ScriptOrigin& self) {
return ptr_to_local(&self)->ScriptId();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also removed these ptr_to_local calls as v8::ScriptOrigin is not meant to be inside of a v8::Local<>, and at best this does nothing since Local::operator-> just returns the original pointer again.

@goffrie goffrie changed the title Fix memory leak in Function::GetScriptOrigin Fix memory leak in Function::get_script_origin Jan 21, 2026
@bartlomieju bartlomieju requested a review from devsnek January 21, 2026 10:17
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