From c0097db48cd8b2809fe7ffa8339b3e1e704d4bf8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 22 Nov 2012 17:36:49 +0800 Subject: [PATCH] Avoiding pointer point to a destroyed variable. --- scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp index bc701cbe7e..c05238415b 100644 --- a/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp +++ b/scripting/javascript/bindings/js_bindings_chipmunk_manual.cpp @@ -430,8 +430,9 @@ JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrame__static(JSContext *cx, uint JSBool JSPROXY_CCPhysicsSprite_spriteWithSpriteFrameName__static(JSContext *cx, uint32_t argc, jsval *vp) { jsval *argv = JS_ARGV(cx, vp); const char* arg0; + std::string arg0_tmp; if (argc >= 1) { - std::string arg0_tmp = jsval_to_std_string(cx, argv[0]); arg0 = arg0_tmp.c_str(); + arg0_tmp = jsval_to_std_string(cx, argv[0]); arg0 = arg0_tmp.c_str(); } CCPhysicsSprite* ret = new CCPhysicsSprite(); ret->initWithSpriteFrameName(arg0);