From 3ec0e0943c25ccb2f0ec22cfbcbf1cf4760435b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=BChrk?= Date: Sun, 19 Oct 2014 01:22:04 +0200 Subject: [PATCH] TIFF loader: Allocate large enough buffer when (bpp * ncn) > 8. Conflicts: modules/highgui/src/grfmt_tiff.cpp floodfill return value removed --- modules/imgcodecs/src/grfmt_tiff.cpp | 11 ++++++----- modules/imgproc/src/floodfill.cpp | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index 59b40ceff..fc6f2368a 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -247,7 +247,8 @@ bool TiffDecoder::readData( Mat& img ) (!is_tiled && tile_height0 == std::numeric_limits::max()) ) tile_height0 = m_height; - AutoBuffer _buffer( size_t(8) * tile_height0*tile_width0); + const size_t buffer_size = bpp * ncn * tile_height0 * tile_width0; + AutoBuffer _buffer( buffer_size ); uchar* buffer = _buffer; ushort* buffer16 = (ushort*)buffer; float* buffer32 = (float*)buffer; @@ -313,9 +314,9 @@ bool TiffDecoder::readData( Mat& img ) case 16: { if( !is_tiled ) - ok = (int)TIFFReadEncodedStrip( tif, tileidx, (uint32*)buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedStrip( tif, tileidx, (uint32*)buffer, buffer_size ) >= 0; else - ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, buffer_size ) >= 0; if( !ok ) { @@ -384,9 +385,9 @@ bool TiffDecoder::readData( Mat& img ) case 64: { if( !is_tiled ) - ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, buffer_size ) >= 0; else - ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, (tsize_t)-1 ) >= 0; + ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, buffer_size ) >= 0; if( !ok || ncn != 1 ) { diff --git a/modules/imgproc/src/floodfill.cpp b/modules/imgproc/src/floodfill.cpp index 69228b339..6d8491a2a 100644 --- a/modules/imgproc/src/floodfill.cpp +++ b/modules/imgproc/src/floodfill.cpp @@ -487,7 +487,6 @@ int cv::floodFill( InputOutputArray _image, InputOutputArray _mask, if ( (cn != 1) && (cn != 3) ) { CV_Error( CV_StsBadArg, "Number of channels in input image must be 1 or 3" ); - return; } if( connectivity == 0 )