From 9ddaab2efe7ffbd9744dd4677164589fbfc7b0bd Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Fri, 15 Aug 2025 17:16:34 +0800 Subject: [PATCH 1/2] fix codebug from review Signed-off-by: fanzhihao8 --- .../src/image_fwk_image_source2_fuzzer.cpp | 1 + .../test/unittest/image_format_convert_test.cpp | 12 ++++++++---- .../innerkitsimpl/test/unittest/jpg_yuv_test.cpp | 12 ++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/frameworks/innerkitsimpl/test/fuzztest/imagefwkimagesource2_fuzzer/src/image_fwk_image_source2_fuzzer.cpp b/frameworks/innerkitsimpl/test/fuzztest/imagefwkimagesource2_fuzzer/src/image_fwk_image_source2_fuzzer.cpp index 922f7a3f5..20f0d26bf 100644 --- a/frameworks/innerkitsimpl/test/fuzztest/imagefwkimagesource2_fuzzer/src/image_fwk_image_source2_fuzzer.cpp +++ b/frameworks/innerkitsimpl/test/fuzztest/imagefwkimagesource2_fuzzer/src/image_fwk_image_source2_fuzzer.cpp @@ -159,6 +159,7 @@ void CreateImageSourceByFDEXFuzz(const std::string &pathName) SetFdpDecodeOptions(FDP, dopts); if (imagesource != nullptr) { imagesource->CreatePixelMap(dopts, errorCode); + imagesource->RemoveImageProperties(0, {"ImageWidth", "ImageHeight"}, fd); } close(fd); } diff --git a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp index affe02cfa..77f2b7de3 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp @@ -249,20 +249,24 @@ bool ImageFormatConvertTest::ReadFile(void *chOrg, std::string path, int32_t tot GTEST_LOG_(INFO) << "fopen"; return false; } + + bool result = true; if (srcNum == 0) { size_t bytesOrg = fread(chOrg, sizeof(uint8_t), static_cast(totalsize), fileOrg); if (bytesOrg < static_cast(totalsize)) { GTEST_LOG_(INFO) << "Read fail"; - return false; + result = false; } } else { size_t bytesOrg = fread(chOrg, sizeof(uint16_t), static_cast(totalsize), fileOrg); if (bytesOrg < static_cast(totalsize)) { - GTEST_LOG_(INFO) << "Read fail " << bytesOrg << " totalsize" << totalsize; - return false; + GTEST_LOG_(INFO) << "Read fail " << bytesOrg << " totalsize " << totalsize; + result = false; } } - return true; + + fclose(fileOrg); + return result; } void ImageFormatConvertTest::YuvP010ConvertToRgb(PixelFormat &srcFormat, PixelFormat &destFormat, Size &srcSize, diff --git a/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp b/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp index 3afa31144..307f5718a 100644 --- a/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp @@ -602,20 +602,24 @@ bool JpgYuvTest::ReadFile(void *chOrg, std::string path, int32_t totalsize, int3 GTEST_LOG_(INFO) << "Cannot open" << path.c_str(); return false; } + + bool result = true; if (srcNum == 0) { size_t bytesOrg = fread(chOrg, sizeof(uint8_t), static_cast(totalsize), fileOrg); if (bytesOrg < static_cast(totalsize)) { GTEST_LOG_(INFO) << "Read fail"; - return false; + result = false; } } else { size_t bytesOrg = fread(chOrg, sizeof(uint16_t), static_cast(totalsize), fileOrg); if (bytesOrg < static_cast(totalsize)) { - GTEST_LOG_(INFO) << "Read fail " << bytesOrg << " totalsize" << totalsize; - return false; + GTEST_LOG_(INFO) << "Read fail " << bytesOrg << " totalsize " << totalsize; + result = false; } } - return true; + + fclose(fileOrg); + return result; } void JpgYuvTest::YuvP010Crop(PixelFormat outfmt, std::string outname, ImageSize &imageSize) -- Gitee From de4c3f8f4337bb43caf9e5e302f8830d7d0fc84e Mon Sep 17 00:00:00 2001 From: fanzhihao8 Date: Fri, 15 Aug 2025 17:34:15 +0800 Subject: [PATCH 2/2] fix codebug from review Signed-off-by: fanzhihao8 --- .../test/unittest/image_format_convert_test.cpp | 5 ++++- frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp index 77f2b7de3..bac1991d3 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_format_convert_test.cpp @@ -265,7 +265,10 @@ bool ImageFormatConvertTest::ReadFile(void *chOrg, std::string path, int32_t tot } } - fclose(fileOrg); + if (fclose(fileOrg) == EOF) { + GTEST_LOG_(INFO) << "fclose failed"; + result = false; + } return result; } diff --git a/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp b/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp index 307f5718a..e290398e9 100644 --- a/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/jpg_yuv_test.cpp @@ -618,7 +618,10 @@ bool JpgYuvTest::ReadFile(void *chOrg, std::string path, int32_t totalsize, int3 } } - fclose(fileOrg); + if (fclose(fileOrg) == EOF) { + GTEST_LOG_(INFO) << "fclose failed"; + result = false; + } return result; } -- Gitee