From d2e7d723c77c7713b4c8f359d125a6eb47db6136 Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Thu, 10 Mar 2022 23:08:09 +0800 Subject: [PATCH 1/2] Modify ptr mem error Signed-off-by: zhang-xiaobo1997 --- frameworks/innerkitsimpl/common/src/pixel_map.cpp | 4 +++- frameworks/kits/js/common/image_source_napi.cpp | 8 ++++---- interfaces/innerkits/BUILD.gn | 12 +++--------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/frameworks/innerkitsimpl/common/src/pixel_map.cpp b/frameworks/innerkitsimpl/common/src/pixel_map.cpp index b23cc78fc..2063e920c 100644 --- a/frameworks/innerkitsimpl/common/src/pixel_map.cpp +++ b/frameworks/innerkitsimpl/common/src/pixel_map.cpp @@ -1044,7 +1044,6 @@ void PixelMap::ReleaseMemory(AllocatorType allocType, void *addr, void *context, } if (fd != nullptr) { ::close(*fd); - delete fd; } #endif } else if (allocType == AllocatorType::HEAP_ALLOC) { @@ -1338,6 +1337,9 @@ PixelMap *PixelMap::Unmarshalling(Parcel &parcel) uint32_t ret = pixelMap->SetImageInfo(imgInfo); if (ret != SUCCESS) { ReleaseMemory(allocType, base, context, bufferSize); + if (context != nullptr) { + delete static_cast(context); + } HiLog::Error(LABEL, "create pixel map from parcel failed, set image info error."); return nullptr; } diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 1f0b3aca8..3a8003282 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -365,8 +365,8 @@ static bool ParseDecodeOptions(napi_env env, napi_value root, DecodeOptions* opt HiLog::Debug(LABEL, "no sampleSize"); } - if (!GET_UINT32_BY_NAME(root, "rotateDegrees", opts->rotateNewDegrees)) { - HiLog::Debug(LABEL, "no rotateDegrees"); + if (!GET_UINT32_BY_NAME(root, "rotate", opts->rotateNewDegrees)) { + HiLog::Debug(LABEL, "no rotate"); } if (!GET_BOOL_BY_NAME(root, "editable", opts->editable)) { @@ -382,7 +382,7 @@ static bool ParseDecodeOptions(napi_env env, napi_value root, DecodeOptions* opt } if (!GET_NODE_BY_NAME(root, "desiredRegion", tmpValue)) { - HiLog::Debug(LABEL, "no rotateDegrees"); + HiLog::Debug(LABEL, "no desiredRegion"); } else { if (!ParseRegion(env, tmpValue, &(opts->desiredRegion))) { HiLog::Debug(LABEL, "ParseRegion error"); @@ -391,7 +391,7 @@ static bool ParseDecodeOptions(napi_env env, napi_value root, DecodeOptions* opt tmpNumber = 0; if (!GET_UINT32_BY_NAME(root, "desiredPixelFormat", tmpNumber)) { - HiLog::Debug(LABEL, "no rotateDegrees"); + HiLog::Debug(LABEL, "no desiredPixelFormat"); } else { opts->desiredPixelFormat = ParsePixlForamt(tmpNumber); } diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index 76a585f0f..599d2f266 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -31,6 +31,7 @@ config("image_external_config") { "//foundation/multimedia/utils/include", "//foundation/multimedia/image_standard/plugins/manager/include", "//foundation/multimedia/image_standard/interfaces/innerkits/include", + "//foundation/multimedia/image_standard/interfaces/kits/native/include", "//utils/jni/jnikit/include", "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", "//foundation/graphic/standard/interfaces/innerkits/surface", @@ -54,7 +55,6 @@ config("image_external_config") { include_dirs += [ "//utils/native/base/include", "//third_party/libpng", - "//third_party/libjpeg-turbo", "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", ] } @@ -181,10 +181,7 @@ ohos_shared_library("image_native") { if (DUAL_ADAPTER) { } else { - deps += [ - "//third_party/libjpeg-turbo:libjpeg-turbo", - "//third_party/libpng:libpng", - ] + deps += [ "//third_party/libpng:libpng" ] } external_deps = [ "bytrace_standard:bytrace_core", @@ -299,10 +296,7 @@ ohos_static_library("image_static") { if (DUAL_ADAPTER) { } else { - deps += [ - "//third_party/libjpeg-turbo:libjpeg-turbo", - "//third_party/libpng:libpng", - ] + deps += [ "//third_party/libpng:libpng" ] } } subsystem_name = "multimedia" -- Gitee From 1313e1bc1c8127a00fa33910a41617a9e56a1e8f Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Fri, 11 Mar 2022 00:09:29 +0800 Subject: [PATCH 2/2] modify for rotate Signed-off-by: zhang-xiaobo1997 --- frameworks/kits/js/common/image_source_napi.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/kits/js/common/image_source_napi.cpp b/frameworks/kits/js/common/image_source_napi.cpp index 3a8003282..0100147c2 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -367,6 +367,8 @@ static bool ParseDecodeOptions(napi_env env, napi_value root, DecodeOptions* opt if (!GET_UINT32_BY_NAME(root, "rotate", opts->rotateNewDegrees)) { HiLog::Debug(LABEL, "no rotate"); + } else { + opts->rotateDegrees = (float)opts->rotateNewDegrees; } if (!GET_BOOL_BY_NAME(root, "editable", opts->editable)) { -- Gitee