From f5b3a6cc4f6b68b5f793f665eb4f87def9619efa Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Thu, 6 Oct 2022 15:10:59 +0900 Subject: [PATCH] [Tizen] Fix a gif crash A crash ocurred when we load a gif file which exists but is not a gif Change-Id: I5f3b2484b0cf8cd825e48922d2d3ba5a2af8b025 --- automated-tests/resources/invalid.gif | Bin 0 -> 260 bytes .../src/dali-adaptor/utc-Dali-GifLoading.cpp | 16 +++++++++++++++- dali/internal/imaging/common/gif-loading.cpp | 11 ++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 automated-tests/resources/invalid.gif diff --git a/automated-tests/resources/invalid.gif b/automated-tests/resources/invalid.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ec84aed177ff411b63814653a5ccb0966341248 GIT binary patch literal 260 zcmWO1u}Z^07y#h3L`b(7n!Qbv;SL|b%@Cr5n~t;ps-621SENI6EDgBXh6u?Y9OEYG z&__@Q!9|?i>QJ=5{odd+j9w@K#wf75O literal 0 HcmV?d00001 diff --git a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp index b71cedd..03267a7 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-GifLoading.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,9 @@ static const char* gGif_100_None = TEST_RESOURCE_DIR "/canvas-none.gif"; // this image if not exist, for negative test static const char* gGifNonExist = "non-exist.gif"; +// this image exists but it is not a gif file. +static const char* gGifInvalid = TEST_RESOURCE_DIR "/invalid.gif"; + } // namespace void utc_dali_animated_image_loader_startup(void) @@ -65,3 +68,14 @@ int UtcDaliAnimatedImageLoadingGetImageSizeN(void) END_TEST; } + +int UtcDaliAnimatedImageLoadingInvalidGif(void) +{ + Dali::AnimatedImageLoading animatedImageLoading = Dali::AnimatedImageLoading::New(gGifInvalid, true); + Dali::Devel::PixelBuffer pixelBuffer = animatedImageLoading.LoadFrame(0); + + // The pixel buffer should be empty. + DALI_TEST_CHECK(!pixelBuffer); + + END_TEST; +} diff --git a/dali/internal/imaging/common/gif-loading.cpp b/dali/internal/imaging/common/gif-loading.cpp index 4ca7dd4..88b8e1e 100644 --- a/dali/internal/imaging/common/gif-loading.cpp +++ b/dali/internal/imaging/common/gif-loading.cpp @@ -1078,6 +1078,11 @@ bool ReadHeader(LoaderInfo& loaderInfo, } } } + else + { + success = false; + DALI_LOG_ERROR("LOAD_ERROR_UNKNOWN_FORMAT\n"); + } } return success; } @@ -1396,7 +1401,7 @@ public: mLoadSucceeded(false), mMutex() { - loaderInfo.gifAccessor = nullptr; + loaderInfo.gifAccessor = nullptr; loaderInfo.fileData.fileName = mUrl.c_str(); loaderInfo.fileData.isLocalResource = isLocalResource; } @@ -1411,6 +1416,10 @@ public: } mLoadSucceeded = ReadHeader(loaderInfo, imageProperties); + if(!mLoadSucceeded) + { + DALI_LOG_ERROR("ReadHeader is failed [%s]\n", mUrl.c_str()); + } return mLoadSucceeded; } -- 2.7.4