From: Joogab Yun Date: Mon, 8 Jul 2019 08:14:04 +0000 (+0900) Subject: prevent out of bounds X-Git-Tag: dali_1.4.28~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b0e2a7f8d06fde846298592837afa5ccf1d5880;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git prevent out of bounds If bytesPerPixel is 0, the alphaIndex value is 4294967295. const unsigned int bytesPerPixel = Dali::Pixel::GetBytesPerPixel(pixelFormat); const unsigned int alphaIndex = bytesPerPixel - 1u; Change-Id: Ia7c1dc67d913141bd8d2c2fad062d7d861843fd1 --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Circular.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Circular.cpp index 9a6d206..ae3afd2 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Circular.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Circular.cpp @@ -797,6 +797,10 @@ int UtcDaliTextUpdateBufferFormatCheck(void) Dali::Toolkit::DevelText::UpdateBuffer(srcBuffer, dstBuffer, 0, 0, true); + Devel::PixelBuffer compressedSrcBuffer = Devel::PixelBuffer::New( 10, 10, Pixel::COMPRESSED_R11_EAC ); + Devel::PixelBuffer compressedDstBuffer = Devel::PixelBuffer::New( 10, 10, Pixel::COMPRESSED_R11_EAC ); + Dali::Toolkit::DevelText::UpdateBuffer(compressedSrcBuffer, compressedDstBuffer, 0, 0, true); + tet_result(TET_PASS); END_TEST; } diff --git a/dali-toolkit/devel-api/text/text-utils-devel.cpp b/dali-toolkit/devel-api/text/text-utils-devel.cpp index dcc9ab8..eaab0e5 100755 --- a/dali-toolkit/devel-api/text/text-utils-devel.cpp +++ b/dali-toolkit/devel-api/text/text-utils-devel.cpp @@ -1281,6 +1281,10 @@ void UpdateBuffer(Devel::PixelBuffer src, Devel::PixelBuffer dst, unsigned int x } const unsigned int bytesPerPixel = Dali::Pixel::GetBytesPerPixel(pixelFormat); + if( bytesPerPixel == 0u ) + { + return; + } const unsigned int alphaIndex = bytesPerPixel - 1u; const unsigned char* const srcBuffer = src.GetBuffer();