!2453 异常返回前释放资源

Merge pull request !2453 from hanxuejian/peronal/hxj/delctx
This commit is contained in:
openharmony_ci 2024-11-16 02:14:13 +00:00 committed by Gitee
commit d83eb6b6ba
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -158,6 +158,8 @@ napi_value NapiCreateAsyncWork3(const AsyncPara &para, AsyncContextType *asyncCo
if (errCode.has_value()) { if (errCode.has_value()) {
JsError error = NapiUtil::ConverErrorMessageForJs(errCode.value()); JsError error = NapiUtil::ConverErrorMessageForJs(errCode.value());
NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); NapiUtil::ThrowError(env, error.errorCode, error.errorMessage);
delete asyncContext;
asyncContext = nullptr;
return nullptr; return nullptr;
} }
} }
@ -165,6 +167,8 @@ napi_value NapiCreateAsyncWork3(const AsyncPara &para, AsyncContextType *asyncCo
if (errCode.has_value()) { if (errCode.has_value()) {
JsError error = NapiUtil::ConverErrorMessageForJs(errCode.value()); JsError error = NapiUtil::ConverErrorMessageForJs(errCode.value());
NapiUtil::ThrowError(env, error.errorCode, error.errorMessage); NapiUtil::ThrowError(env, error.errorCode, error.errorMessage);
delete asyncContext;
asyncContext = nullptr;
return nullptr; return nullptr;
} }
} }