Skip to content

Commit

Permalink
RN-2841 Memory leak with fetch function
Browse files Browse the repository at this point in the history
From:
facebook/react-native#25884

String data passed from native to js would leak a JSStringRef.
  • Loading branch information
AnthonyBongersYoui committed Apr 3, 2020
1 parent f17cb9b commit 3e60682
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 3e60682

Please sign in to comment.