mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #26699 from vrabaud:bmp_overflow
Fix integer overflow in in cv::BmpDecoder::readHeader
This commit is contained in:
commit
f65006eee1
@ -208,7 +208,12 @@ bool BmpDecoder::readHeader()
|
||||
// in 32 bit case alpha channel is used - so require CV_8UC4 type
|
||||
m_type = iscolor ? ((m_bpp == 32 && m_rle_code != BMP_RGB) ? CV_8UC4 : CV_8UC3 ) : CV_8UC1;
|
||||
m_origin = m_height > 0 ? ORIGIN_BL : ORIGIN_TL;
|
||||
m_height = std::abs(m_height);
|
||||
if ( m_height == std::numeric_limits<int>::min() ) {
|
||||
// abs(std::numeric_limits<int>::min()) is undefined behavior.
|
||||
result = false;
|
||||
} else {
|
||||
m_height = std::abs(m_height);
|
||||
}
|
||||
|
||||
if( !result )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user