Fix CreatePicture Napi OOM

Issue: https://gitee.com/openharmony/multimedia_image_framework/issues/IAYISF

Signed-off-by: caochuan <caochuan@huawei.com>
Change-Id: Iaf2ae3435f8e7dfafbae0e446aced190fa06602a
This commit is contained in:
caochuan 2024-10-21 13:54:30 +08:00
parent fbfa910f04
commit 851e0719d8
2 changed files with 3 additions and 3 deletions

View File

@ -304,7 +304,7 @@ napi_value PictureNapi::Constructor(napi_env env, napi_callback_info info)
std::unique_ptr<PictureNapi> pPictureNapi = std::make_unique<PictureNapi>();
if (pPictureNapi != nullptr) {
pPictureNapi->env_ = env;
pPictureNapi->nativePicture_ = sPicture_;
pPictureNapi->nativePicture_ = std::move(sPicture_);
if (pPictureNapi->nativePicture_ == nullptr) {
IMAGE_LOGE("Failed to set nativePicture_ with null. Maybe a reentrancy error");
}
@ -327,7 +327,7 @@ void PictureNapi::Destructor(napi_env env, void *nativeObject, void *finalize)
}
}
napi_value PictureNapi::CreatePicture(napi_env env, std::shared_ptr<Picture> picture)
napi_value PictureNapi::CreatePicture(napi_env env, std::shared_ptr<Picture> &picture)
{
if (sConstructor_ == nullptr) {
napi_value exports = nullptr;

View File

@ -30,7 +30,7 @@ public:
static napi_value Init(napi_env env, napi_value exports);
static std::shared_ptr<Picture> GetPicture(napi_env env, napi_value picture);
static napi_value CreatePicture(napi_env env, std::shared_ptr<Picture> picture);
static napi_value CreatePicture(napi_env env, std::shared_ptr<Picture> &picture);
static int32_t CreatePictureNapi(napi_env env, napi_value* result);
void SetNativePicture(std::shared_ptr<Picture> picture);