Skip to content

Verify memory leak fix already present in JavaScriptUtils.cpp#113

Closed
Copilot wants to merge 1 commit into
topic/RDKEMW-12252from
copilot/sub-pr-110
Closed

Verify memory leak fix already present in JavaScriptUtils.cpp#113
Copilot wants to merge 1 commit into
topic/RDKEMW-12252from
copilot/sub-pr-110

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 4, 2026

Review feedback indicated a potential memory leak in rtReadBinaryBinding() where a malloc'd buffer could leak if setString() throws. Analysis confirms the base commit already implements the correct fix.

Implementation Status

The code uses std::unique_ptr<char, decltype(&free)> as a RAII wrapper:

std::unique_ptr<char, decltype(&free)> buffer(static_cast<char*>(malloc(size + 1)), &free);
if (!buffer) {
  rtLogError("Failed to allocate memory for file buffer");
  fclose(ptr);
  return RT_ERROR;
}
// ... later ...
if (result) {
  result->setString(buffer.get());  // Exception-safe: buffer auto-freed on unwind
}

This ensures automatic cleanup on both normal return paths and exception scenarios. No additional changes required.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Work in progress to address feedback on fixing issues Verify memory leak fix already present in JavaScriptUtils.cpp Feb 4, 2026
Copilot AI requested a review from vjain008 February 4, 2026 22:10
@vjain008 vjain008 closed this Feb 4, 2026
@vjain008 vjain008 deleted the copilot/sub-pr-110 branch February 4, 2026 22:14
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants