From 1231e4c2bf0dfb534eb26e4038b30f23c6399072 Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Thu, 10 Mar 2022 22:09:29 +0800 Subject: [PATCH 1/3] Moidfy for mem error Signed-off-by: zhang-xiaobo1997 --- frameworks/innerkitsimpl/common/src/pixel_map.cpp | 4 +++- frameworks/kits/js/common/image_source_napi.cpp | 4 ++-- interfaces/innerkits/BUILD.gn | 3 --- 3 files changed, 5 insertions(+), 6 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 6742eac26..576f85d2e 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -387,7 +387,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"); @@ -396,7 +396,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 50d869676..ddcffe642 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -55,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", ] } @@ -183,7 +182,6 @@ ohos_shared_library("image_native") { if (DUAL_ADAPTER) { } else { deps += [ - "//third_party/libjpeg-turbo:libjpeg-turbo", "//third_party/libpng:libpng", ] } @@ -301,7 +299,6 @@ ohos_static_library("image_static") { if (DUAL_ADAPTER) { } else { deps += [ - "//third_party/libjpeg-turbo:libjpeg-turbo", "//third_party/libpng:libpng", ] } -- Gitee From 8343ddd305c5bf8f6ee495a468af23eb42e59ed3 Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Thu, 10 Mar 2022 22:39:30 +0800 Subject: [PATCH 2/3] modify for format Signed-off-by: zhang-xiaobo1997 --- interfaces/innerkits/BUILD.gn | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/interfaces/innerkits/BUILD.gn b/interfaces/innerkits/BUILD.gn index ddcffe642..599d2f266 100644 --- a/interfaces/innerkits/BUILD.gn +++ b/interfaces/innerkits/BUILD.gn @@ -181,9 +181,7 @@ ohos_shared_library("image_native") { if (DUAL_ADAPTER) { } else { - deps += [ - "//third_party/libpng:libpng", - ] + deps += [ "//third_party/libpng:libpng" ] } external_deps = [ "bytrace_standard:bytrace_core", @@ -298,9 +296,7 @@ ohos_static_library("image_static") { if (DUAL_ADAPTER) { } else { - deps += [ - "//third_party/libpng:libpng", - ] + deps += [ "//third_party/libpng:libpng" ] } } subsystem_name = "multimedia" -- Gitee From 5a2aecb46f7521adf3b2917854ee5cad1d717e19 Mon Sep 17 00:00:00 2001 From: zhang-xiaobo1997 Date: Fri, 11 Mar 2022 00:05:07 +0800 Subject: [PATCH 3/3] 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 576f85d2e..1b62e57b5 100644 --- a/frameworks/kits/js/common/image_source_napi.cpp +++ b/frameworks/kits/js/common/image_source_napi.cpp @@ -372,6 +372,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