From 9b0e2a7f8d06fde846298592837afa5ccf1d5880 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Mon, 8 Jul 2019 17:14:04 +0900 Subject: [PATCH] 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 --- automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Circular.cpp | 4 ++++ dali-toolkit/devel-api/text/text-utils-devel.cpp | 4 ++++ 2 files changed, 8 insertions(+) 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(); -- 2.7.4