From e86dc94ee9d9f15e487ce7d4823e5c3b3832589d Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Mon, 2 Nov 2015 11:59:33 -0800 Subject: [PATCH] Plug small leak from not releasing a JSStringRef --- src/js_object.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/js_object.cpp b/src/js_object.cpp index 0938b493..2112df42 100644 --- a/src/js_object.cpp +++ b/src/js_object.cpp @@ -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) { JSObjectRef object = RJSValidatedValueToObject(ctx, dict); - JSStringRef propStr =JSStringCreateWithUTF8CString(prop_name.c_str()); - return JSObjectHasProperty(ctx, object, propStr); + JSStringRef propStr = RJSStringForString(prop_name); + 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) { JSObjectRef object = RJSValidatedValueToObject(ctx, dict); - JSStringRef propStr =JSStringCreateWithUTF8CString(prop_name.c_str()); + JSStringRef propStr = RJSStringForString(prop_name); JSValueRef ex = NULL; JSValueRef ret = JSObjectGetProperty(ctx, object, propStr, &ex); if (ex) {