diff --git a/scripting/javascript/bindings/ScriptingCore.h b/scripting/javascript/bindings/ScriptingCore.h index 2ce1d9e237..6a75440f96 100644 --- a/scripting/javascript/bindings/ScriptingCore.h +++ b/scripting/javascript/bindings/ScriptingCore.h @@ -294,6 +294,10 @@ public: operator char*() { return (char*)buffer; } +private: + /* Copy and assignment are not supported. */ + JSStringWrapper(const JSStringWrapper &another); + JSStringWrapper &operator=(const JSStringWrapper &another); }; JSBool jsb_set_reserved_slot(JSObject *obj, uint32_t idx, jsval value); diff --git a/scripting/javascript/bindings/js_bindings_core.cpp b/scripting/javascript/bindings/js_bindings_core.cpp index 8297f7b011..8ab4105c69 100644 --- a/scripting/javascript/bindings/js_bindings_core.cpp +++ b/scripting/javascript/bindings/js_bindings_core.cpp @@ -80,8 +80,11 @@ JSBool JSBCore_log(JSContext *cx, uint32_t argc, jsval *vp) JSString *string = NULL; JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); if (string) { - JSAutoByteString log_str(cx, string); - CCLOG(log_str.ptr()); + char* log_str = JS_EncodeString(cx, string); + if (log_str) { + CCLOG(log_str); + JS_free(cx, (void*)log_str); + } } return JS_TRUE;