...
 
Commits (2)
    https://gitcode.net/openharmony/communication_ipc/-/commit/02ba89c34eccb372517c82084e3f6ccef5e9066e fix use env after free of param in napi_remote_object 2023-08-02T08:53:15+00:00 shufewhx wanghaoxu1@huawei.com Signed-off-by: <span data-trailer="Signed-off-by:"><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com"></a><a href="javascript:void(0)" class="avatar s16 avatar-inline identicon bg4" style="text-decoration: none">N</a><a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">shufewhx</a> &lt;<a href="mailto:wanghaoxu1@huawei.com" title="wanghaoxu1@huawei.com">wanghaoxu1@huawei.com</a>&gt;</span> https://gitcode.net/openharmony/communication_ipc/-/commit/88c4327ea0025acb261eda23ae7fc97f0b850d4f !753 [3.2-Release]fix use env after free of param in napi_remote_object 2023-08-21T03:06:57+00:00 openharmony_ci 120357966@qq.com Merge pull request !753 from wanghaoxu/OpenHarmony-3.2-Release
......@@ -730,22 +730,6 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
// Start to call promiseThen
napi_value then_return_value;
ret = napi_call_function(param->env, return_val, promiseThen, 1, &then_value, &then_return_value);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "PromiseThen got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
// Create promiseCatch
napi_value promiseCatch = nullptr;
napi_get_named_property(param->env, return_val, "catch", &promiseCatch);
if (promiseCatch == nullptr) {
ZLOGE(LOG_LABEL, "get promiseCatch failed");
param->result = -1;
break;
}
napi_value catch_value;
ret = napi_create_function(param->env, "catchCallback",
NAPI_AUTO_LENGTH, CatchCallback, param, &catch_value);
......@@ -754,15 +738,18 @@ int NAPIRemoteObject::OnJsRemoteRequest(CallbackParam *jsParam)
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
// Start to call promiseCatch
napi_value catch_return_value;
ret = napi_call_function(param->env, return_val, promiseCatch, 1, &catch_value, &catch_return_value);
// Start to call promiseThen
napi_env env = param->env;
napi_value thenReturnValue;
constexpr uint32_t THEN_ARGC = 2;
napi_value thenArgv[THEN_ARGC] = {then_value, catch_value};
ret = napi_call_function(env, return_val, promiseThen, THEN_ARGC, thenArgv, &thenReturnValue);
if (ret != napi_ok) {
ZLOGE(LOG_LABEL, "PromiseCatch got exception");
ZLOGE(LOG_LABEL, "PromiseThen got exception");
param->result = ERR_UNKNOWN_TRANSACTION;
break;
}
napi_close_handle_scope(param->env, scope);
napi_close_handle_scope(env, scope);
return;
} while (0);
......