Plug small leak from not releasing a JSStringRef

This commit is contained in:
Scott Kyle 2015-11-02 11:59:33 -08:00
parent 213c3d832f
commit e86dc94ee9
1 changed files with 6 additions and 3 deletions

View File

@ -65,13 +65,16 @@ JSObjectRef RJSObjectCreate(JSContextRef ctx, Object object) {
template<> bool RJSAccessor::dict_has_value_for_key(JSContextRef ctx, JSValueRef dict, const std::string &prop_name) { template<> bool RJSAccessor::dict_has_value_for_key(JSContextRef ctx, JSValueRef dict, const std::string &prop_name) {
JSObjectRef object = RJSValidatedValueToObject(ctx, dict); JSObjectRef object = RJSValidatedValueToObject(ctx, dict);
JSStringRef propStr =JSStringCreateWithUTF8CString(prop_name.c_str()); JSStringRef propStr = RJSStringForString(prop_name);
return JSObjectHasProperty(ctx, object, propStr); bool ret = JSObjectHasProperty(ctx, object, propStr);
JSStringRelease(propStr);
return ret;
} }
template<> JSValueRef RJSAccessor::dict_value_for_key(JSContextRef ctx, JSValueRef dict, const std::string &prop_name) { template<> JSValueRef RJSAccessor::dict_value_for_key(JSContextRef ctx, JSValueRef dict, const std::string &prop_name) {
JSObjectRef object = RJSValidatedValueToObject(ctx, dict); JSObjectRef object = RJSValidatedValueToObject(ctx, dict);
JSStringRef propStr =JSStringCreateWithUTF8CString(prop_name.c_str()); JSStringRef propStr = RJSStringForString(prop_name);
JSValueRef ex = NULL; JSValueRef ex = NULL;
JSValueRef ret = JSObjectGetProperty(ctx, object, propStr, &ex); JSValueRef ret = JSObjectGetProperty(ctx, object, propStr, &ex);
if (ex) { if (ex) {