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) {