You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/01/08 02:13:09 UTC

[GitHub] lvfen closed pull request #2009: [Android] fix callGcanvas导致的野指针问题

lvfen closed pull request #2009: [Android] fix callGcanvas导致的野指针问题
URL: https://github.com/apache/incubator-weex/pull/2009
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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..c5bea35a52 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,15 @@ static std::unique_ptr<IPCResult> HandleCallGCanvasLinkNative(
 //    retVal = WeexCoreManager::Instance()->script_bridge()->core_side()->CallGCanvasLinkNative(pageId, type,
 //                                                                                     args);
 
-      std::unique_ptr<IPCResult> ret = createVoidResult();
-      if (retVal) {
+  std::unique_ptr<IPCResult> ret = createVoidResult();
+  if (retVal) {
     jstring jDataStr = env->NewStringUTF(retVal);
     ret = std::unique_ptr<IPCResult>(
-        new IPCStringResult(jstring2WeexString(env, jDataStr)));
+            new IPCStringResult(jstring2WeexString(env, jDataStr)));
     env->DeleteLocalRef(jDataStr);
+    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..0fc314782b 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,12 @@ 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));
+    delete resultChar;
+    return ret;
 }
 
 JSFUNCTION functionT3DLinkNative(ExecState *state) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services