From: seungho baek Date: Tue, 2 Jan 2024 01:48:58 +0000 (+0900) Subject: [Tizen] Prevent to decode png when the pixel buffer cannot be created X-Git-Tag: accepted/tizen/8.0/unified/20240109.155450~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F303535%2F1;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [Tizen] Prevent to decode png when the pixel buffer cannot be created Change-Id: Ibf86d02ae4f55590d6f021ac9ebc27b0cfe516fc Signed-off-by: seungho baek --- diff --git a/dali/internal/imaging/common/loader-png.cpp b/dali/internal/imaging/common/loader-png.cpp index a84b205..8351aa7 100644 --- a/dali/internal/imaging/common/loader-png.cpp +++ b/dali/internal/imaging/common/loader-png.cpp @@ -300,6 +300,18 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel break; } } + + // decode the whole image into bitmap buffer + auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer(); + + DALI_ASSERT_DEBUG(pixels); + + if(!pixels) + { + DALI_LOG_ERROR("PixelBuffer couldn't be created\n"); + return false; + } + rows = reinterpret_cast(malloc(sizeof(png_bytep) * height)); if(DALI_UNLIKELY(!rows)) { @@ -307,11 +319,6 @@ bool LoadBitmapFromPng(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel return false; } - // decode the whole image into bitmap buffer - auto pixels = (bitmap = Dali::Devel::PixelBuffer::New(bufferWidth, bufferHeight, pixelFormat)).GetBuffer(); - - DALI_ASSERT_DEBUG(pixels); - for(y = 0; y < height; y++) { rows[y] = pixels + y * stride;