imgcodecs(sunras): avoid undefined shift
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sun, 31 Mar 2019 12:14:42 +0000 (12:14 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Sun, 31 Mar 2019 12:14:42 +0000 (12:14 +0000)
oss-fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=13292

modules/imgcodecs/src/grfmt_sunras.cpp

index a59cc47..31c0286 100644 (file)
@@ -90,7 +90,7 @@ bool  SunRasterDecoder::readHeader()
         m_width  = m_strm.getDWord();
         m_height = m_strm.getDWord();
         m_bpp    = m_strm.getDWord();
-        int palSize = 3*(1 << m_bpp);
+        int palSize = (m_bpp > 0 && m_bpp <= 8) ? (3*(1 << m_bpp)) : 0;
 
         m_strm.skip( 4 );
         m_encoding = (SunRasType)m_strm.getDWord();