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

This commit is contained in:
Luis Lucas
2016-06-06 13:51:39 +01:00
parent 72fec7e6e0
commit fcfd2d5da1
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -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;