Fix crashing when actual number of bits is larger than the specified one.

This commit is contained in:
Luis Lucas committed 2016-06-06 13:51:39 +01:00
1 parent 72fec7e6e0
commit fcfd2d5da1
2 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -148,7 +148,7 @@ IF( USE_WERROR )
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror" ) SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror" )
ENDIF() ENDIF()
SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g" ) SET( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0" )
SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" ) SET( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
+5
View File
@@ -576,6 +576,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
Int endByte = bytesPixel; Int endByte = bytesPixel;
Int incByte = 1; Int incByte = 1;
Int b; Int b;
Int maxval = pow(2, d->m_uiBitsPel) - 1;
if( d->m_iEndianness == 0 ) if( d->m_iEndianness == 0 )
{ {
@@ -608,6 +609,10 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
{ {
*pPel += *pTmpBuff << ( b * 8 ); *pPel += *pTmpBuff << ( b * 8 );
pTmpBuff++; pTmpBuff++;
// Check max value and bound it to "maxval" to prevent segfault when calculating histogram
if(*pPel > maxval)
*pPel = 0;
// -----
} }
pPel++; pPel++;
pTmpBuff += step; pTmpBuff += step;