Fix crashing when actual number of bits is larger than the specified one.
This commit is contained in:
+1
-1
@@ -148,7 +148,7 @@ IF( USE_WERROR )
|
||||
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror" )
|
||||
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" )
|
||||
|
||||
|
||||
|
||||
@@ -576,6 +576,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
|
||||
Int endByte = bytesPixel;
|
||||
Int incByte = 1;
|
||||
Int b;
|
||||
Int maxval = pow(2, d->m_uiBitsPel) - 1;
|
||||
|
||||
if( d->m_iEndianness == 0 )
|
||||
{
|
||||
@@ -608,6 +609,10 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
|
||||
{
|
||||
*pPel += *pTmpBuff << ( b * 8 );
|
||||
pTmpBuff++;
|
||||
// Check max value and bound it to "maxval" to prevent segfault when calculating histogram
|
||||
if(*pPel > maxval)
|
||||
*pPel = 0;
|
||||
// -----
|
||||
}
|
||||
pPel++;
|
||||
pTmpBuff += step;
|
||||
|
||||
Reference in New Issue
Block a user