From 851e0719d82150c245c1d43b1b227553a6c3bd30 Mon Sep 17 00:00:00 2001 From: caochuan Date: Mon, 21 Oct 2024 13:54:30 +0800 Subject: [PATCH] Fix CreatePicture Napi OOM Issue: https://gitee.com/openharmony/multimedia_image_framework/issues/IAYISF Signed-off-by: caochuan Change-Id: Iaf2ae3435f8e7dfafbae0e446aced190fa06602a --- frameworks/kits/js/common/picture_napi.cpp | 4 ++-- interfaces/kits/js/common/include/picture_napi.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frameworks/kits/js/common/picture_napi.cpp b/frameworks/kits/js/common/picture_napi.cpp index f322d7f24..5cdc2c41c 100644 --- a/frameworks/kits/js/common/picture_napi.cpp +++ b/frameworks/kits/js/common/picture_napi.cpp @@ -304,7 +304,7 @@ napi_value PictureNapi::Constructor(napi_env env, napi_callback_info info) std::unique_ptr pPictureNapi = std::make_unique(); 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) +napi_value PictureNapi::CreatePicture(napi_env env, std::shared_ptr &picture) { if (sConstructor_ == nullptr) { napi_value exports = nullptr; diff --git a/interfaces/kits/js/common/include/picture_napi.h b/interfaces/kits/js/common/include/picture_napi.h index 95eb166f6..92da33d39 100644 --- a/interfaces/kits/js/common/include/picture_napi.h +++ b/interfaces/kits/js/common/include/picture_napi.h @@ -30,7 +30,7 @@ public: static napi_value Init(napi_env env, napi_value exports); static std::shared_ptr GetPicture(napi_env env, napi_value picture); - static napi_value CreatePicture(napi_env env, std::shared_ptr picture); + static napi_value CreatePicture(napi_env env, std::shared_ptr &picture); static int32_t CreatePictureNapi(napi_env env, napi_value* result); void SetNativePicture(std::shared_ptr picture);