diff --git a/modules/highgui/src/grfmt_bmp.cpp b/modules/highgui/src/grfmt_bmp.cpp index 4e12882f50..de60ca6f61 100644 --- a/modules/highgui/src/grfmt_bmp.cpp +++ b/modules/highgui/src/grfmt_bmp.cpp @@ -367,6 +367,9 @@ decode_rle4_bad: ; gray_palette[code] ); line_end_flag = y - prev_y; + + if( y >= m_height ) + break; } else if( code > 2 ) // absolute mode {