Skip to content

Commit

Permalink
Memory Leak due to JSStringRelease not called in multiple places in J…
Browse files Browse the repository at this point in the history
…SCRuntime.cpp (#25884)

Summary:
Memory Leak due to JSStringRelease not called in multiple places in JSCRuntime.cpp
Issue: #25664
Reproducible repo: https://github.com/bhandarijiwan/memory_issue_repro

## Changelog
[JSC] [JSCRuntime.cpp] - Added missing JSStringRelease calls in missing places
Pull Request resolved: #25884

Test Plan: Tested that is no memory leak with various NativeModule to JS call flows

Reviewed By: JoshuaGross

Differential Revision: D16928985

Pulled By: TheSavior

fbshipit-source-id: 65ce15ae32482d0db39bad7e22a2fed9ee04f230
  • Loading branch information
sachinservicemax authored and facebook-github-bot committed Aug 21, 2019
1 parent b26acae commit b8d6ef3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ReactCommon/jsi/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,9 @@ jsi::String JSCRuntime::createStringFromUtf8(
size_t length) {
std::string tmp(reinterpret_cast<const char*>(str), length);
JSStringRef stringRef = JSStringCreateWithUTF8CString(tmp.c_str());
return createString(stringRef);
auto result = createString(stringRef);
JSStringRelease(stringRef);
return result;
}

std::string JSCRuntime::utf8(const jsi::String& str) {
Expand Down

0 comments on commit b8d6ef3

Please sign in to comment.