Skip to content

Commit

Permalink
https://github.com/facebook/react-native/issues/25664
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinservicemax committed Jul 31, 2019
1 parent d285860 commit c3f6857
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions ReactCommon/jsi/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,19 @@ jsi::PropNameID JSCRuntime::createPropNameIDFromString(const jsi::String& str) {
}

std::string JSCRuntime::utf8(const jsi::PropNameID& sym) {
return JSStringToSTLString(stringRef(sym));
JSStringRef strRef = stringRef(sym);
std::string result = JSStringToSTLString(strRef);
JSStringRelease(strRef);
return result;
}

bool JSCRuntime::compare(const jsi::PropNameID& a, const jsi::PropNameID& b) {
return JSStringIsEqual(stringRef(a), stringRef(b));
JSStringRef strRef1 = stringRef(a);
JSStringRef strRef2 = stringRef(b);
bool result = JSStringIsEqual(strRef1, strRef2);
JSStringRelease(strRef1);
JSStringRelease(strRef2);
return result;
}

std::string JSCRuntime::symbolToString(const jsi::Symbol& sym) {
Expand All @@ -630,11 +638,16 @@ 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) {
return JSStringToSTLString(stringRef(str));
JSStringRef strRef = stringRef(str);
std::string result = JSStringToSTLString(strRef);
JSStringRelease(strRef);
return result;
}

jsi::Object JSCRuntime::createObject() {
Expand Down Expand Up @@ -1237,7 +1250,12 @@ bool JSCRuntime::strictEquals(const jsi::Symbol& a, const jsi::Symbol& b)

bool JSCRuntime::strictEquals(const jsi::String& a, const jsi::String& b)
const {
return JSStringIsEqual(stringRef(a), stringRef(b));
JSStringRef strRef1 = stringRef(a);
JSStringRef strRef2 = stringRef(b);
bool result = JSStringIsEqual(strRef1, strRef2);
JSStringRelease(strRef1);
JSStringRelease(strRef2);
return result;
}

bool JSCRuntime::strictEquals(const jsi::Object& a, const jsi::Object& b)
Expand Down

0 comments on commit c3f6857

Please sign in to comment.