diff --git a/weex_core/Source/android/bridge/script_bridge_in_multi_process.cpp b/weex_core/Source/android/bridge/script_bridge_in_multi_process.cpp index 29deee1527..8c2711c2c6 100644 --- a/weex_core/Source/android/bridge/script_bridge_in_multi_process.cpp +++ b/weex_core/Source/android/bridge/script_bridge_in_multi_process.cpp @@ -267,14 +267,17 @@ static std::unique_ptr HandleCallGCanvasLinkNative( // retVal = WeexCoreManager::Instance()->script_bridge()->core_side()->CallGCanvasLinkNative(pageId, type, // args); - std::unique_ptr ret = createVoidResult(); - if (retVal) { - jstring jDataStr = env->NewStringUTF(retVal); - ret = std::unique_ptr( - new IPCStringResult(jstring2WeexString(env, jDataStr))); - env->DeleteLocalRef(jDataStr); - retVal = NULL; + std::unique_ptr ret = createVoidResult(); + if (retVal) { + jstring jDataStr = env->NewStringUTF(retVal); + ret = std::unique_ptr( + new IPCStringResult(jstring2WeexString(env, jDataStr))); + env->DeleteLocalRef(jDataStr); + if (strlen(retVal) > 0) { + delete retVal; } + retVal = NULL; + } // env->DeleteLocalRef(jPageId); // env->DeleteLocalRef(val); return ret; diff --git a/weex_core/Source/android/jsengine/object/weex_global_object.cpp b/weex_core/Source/android/jsengine/object/weex_global_object.cpp index 33952b05d8..0d87c04ee6 100644 --- a/weex_core/Source/android/jsengine/object/weex_global_object.cpp +++ b/weex_core/Source/android/jsengine/object/weex_global_object.cpp @@ -369,9 +369,14 @@ JSFUNCTION functionGCanvasLinkNative(ExecState *state) { JSValue arg_js = state->argument(2); String arg_str = arg_js.toWTFString(state); - auto result = globalObject->js_bridge()->core_side()->CallGCanvasLinkNative(id_str.utf8().data(), + const char * resultChar = globalObject->js_bridge()->core_side()->CallGCanvasLinkNative(id_str.utf8().data(), type, arg_str.utf8().data()); - return JSValue::encode(String2JSValue(state, result)); + auto result = resultChar; + auto ret = JSValue::encode(String2JSValue(state, result)); + if (strlen(resultChar) > 0) { + delete resultChar; + } + return ret; } JSFUNCTION functionT3DLinkNative(ExecState *state) {