Merge pull request #3350 from Trundle:fix_some_tiff_crashes
This commit is contained in:
commit
7bff337828
@ -214,7 +214,8 @@ bool TiffDecoder::readData( Mat& img )
|
|||||||
(!is_tiled && tile_height0 == std::numeric_limits<uint32>::max()) )
|
(!is_tiled && tile_height0 == std::numeric_limits<uint32>::max()) )
|
||||||
tile_height0 = m_height;
|
tile_height0 = m_height;
|
||||||
|
|
||||||
AutoBuffer<uchar> _buffer( size_t(8) * tile_height0*tile_width0);
|
const size_t buffer_size = bpp * ncn * tile_height0 * tile_width0;
|
||||||
|
AutoBuffer<uchar> _buffer( buffer_size );
|
||||||
uchar* buffer = _buffer;
|
uchar* buffer = _buffer;
|
||||||
ushort* buffer16 = (ushort*)buffer;
|
ushort* buffer16 = (ushort*)buffer;
|
||||||
float* buffer32 = (float*)buffer;
|
float* buffer32 = (float*)buffer;
|
||||||
@ -269,9 +270,9 @@ bool TiffDecoder::readData( Mat& img )
|
|||||||
case 16:
|
case 16:
|
||||||
{
|
{
|
||||||
if( !is_tiled )
|
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
|
else
|
||||||
ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, (tsize_t)-1 ) >= 0;
|
ok = (int)TIFFReadEncodedTile( tif, tileidx, (uint32*)buffer, buffer_size ) >= 0;
|
||||||
|
|
||||||
if( !ok )
|
if( !ok )
|
||||||
{
|
{
|
||||||
@ -325,9 +326,9 @@ bool TiffDecoder::readData( Mat& img )
|
|||||||
case 64:
|
case 64:
|
||||||
{
|
{
|
||||||
if( !is_tiled )
|
if( !is_tiled )
|
||||||
ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, (tsize_t)-1 ) >= 0;
|
ok = (int)TIFFReadEncodedStrip( tif, tileidx, buffer, buffer_size ) >= 0;
|
||||||
else
|
else
|
||||||
ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, (tsize_t)-1 ) >= 0;
|
ok = (int)TIFFReadEncodedTile( tif, tileidx, buffer, buffer_size ) >= 0;
|
||||||
|
|
||||||
if( !ok || ncn != 1 )
|
if( !ok || ncn != 1 )
|
||||||
{
|
{
|
||||||
|
@ -516,7 +516,7 @@ TEST(Highgui_Tiff, decode_tile_remainder)
|
|||||||
CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run();
|
CV_GrfmtReadTifTiledWithNotFullTiles test; test.safe_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Imgcodecs_Tiff, decode_infinite_rowsperstrip)
|
TEST(Highgui_Tiff, decode_infinite_rowsperstrip)
|
||||||
{
|
{
|
||||||
const uchar sample_data[142] = {
|
const uchar sample_data[142] = {
|
||||||
0x49, 0x49, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x56, 0x54,
|
0x49, 0x49, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x56, 0x54,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user