@@ -1425,69 +1425,7 @@ RestoreMSCWarning
14251425 case COMPRESSION_ADOBE_DEFLATE : image -> compression = ZipCompression ; break ;
14261426 default : image -> compression = RLECompression ; break ;
14271427 }
1428- /*
1429- Allocate memory for the image and pixel buffer.
1430- */
1431- quantum_info = AcquireQuantumInfo (image_info ,image );
1432- if (quantum_info == (QuantumInfo * ) NULL )
1433- {
1434- TIFFClose (tiff );
1435- ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
1436- }
1437- if (sample_format == SAMPLEFORMAT_UINT )
1438- status = SetQuantumFormat (image ,quantum_info ,UnsignedQuantumFormat );
1439- if (sample_format == SAMPLEFORMAT_INT )
1440- status = SetQuantumFormat (image ,quantum_info ,SignedQuantumFormat );
1441- if (sample_format == SAMPLEFORMAT_IEEEFP )
1442- status = SetQuantumFormat (image ,quantum_info ,FloatingPointQuantumFormat );
1443- if (status == MagickFalse )
1444- {
1445- TIFFClose (tiff );
1446- quantum_info = DestroyQuantumInfo (quantum_info );
1447- ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
1448- }
1449- status = MagickTrue ;
1450- switch (photometric )
1451- {
1452- case PHOTOMETRIC_MINISBLACK :
1453- {
1454- quantum_info -> min_is_white = MagickFalse ;
1455- break ;
1456- }
1457- case PHOTOMETRIC_MINISWHITE :
1458- {
1459- quantum_info -> min_is_white = MagickTrue ;
1460- break ;
1461- }
1462- default :
1463- break ;
1464- }
1465- tiff_status = TIFFGetFieldDefaulted (tiff ,TIFFTAG_EXTRASAMPLES ,& extra_samples ,
1466- & sample_info );
1467- if (tiff_status == 1 )
1468- {
1469- (void ) SetImageProperty (image ,"tiff:alpha" ,"unspecified" ,exception );
1470- if (extra_samples == 0 )
1471- {
1472- if ((samples_per_pixel == 4 ) && (photometric == PHOTOMETRIC_RGB ))
1473- image -> alpha_trait = BlendPixelTrait ;
1474- }
1475- else
1476- for (i = 0 ; i < extra_samples ; i ++ )
1477- {
1478- image -> alpha_trait = BlendPixelTrait ;
1479- if (sample_info [i ] == EXTRASAMPLE_ASSOCALPHA )
1480- {
1481- SetQuantumAlphaType (quantum_info ,DisassociatedQuantumAlpha );
1482- (void ) SetImageProperty (image ,"tiff:alpha" ,"associated" ,
1483- exception );
1484- }
1485- else
1486- if (sample_info [i ] == EXTRASAMPLE_UNASSALPHA )
1487- (void ) SetImageProperty (image ,"tiff:alpha" ,"unassociated" ,
1488- exception );
1489- }
1490- }
1428+ quantum_info = (QuantumInfo * ) NULL ;
14911429 if ((photometric == PHOTOMETRIC_PALETTE ) &&
14921430 (pow (2.0 ,1.0 * bits_per_sample ) <= MaxColormapSize ))
14931431 {
@@ -1554,15 +1492,75 @@ RestoreMSCWarning
15541492 {
15551493 if (image_info -> number_scenes != 0 )
15561494 if (image -> scene >= (image_info -> scene + image_info -> number_scenes - 1 ))
1557- {
1558- quantum_info = DestroyQuantumInfo (quantum_info );
1559- break ;
1560- }
1495+ break ;
15611496 goto next_tiff_frame ;
15621497 }
15631498 status = SetImageExtent (image ,image -> columns ,image -> rows ,exception );
15641499 if (status == MagickFalse )
15651500 return (DestroyImageList (image ));
1501+ /*
1502+ Allocate memory for the image and pixel buffer.
1503+ */
1504+ quantum_info = AcquireQuantumInfo (image_info ,image );
1505+ if (quantum_info == (QuantumInfo * ) NULL )
1506+ {
1507+ TIFFClose (tiff );
1508+ ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
1509+ }
1510+ if (sample_format == SAMPLEFORMAT_UINT )
1511+ status = SetQuantumFormat (image ,quantum_info ,UnsignedQuantumFormat );
1512+ if (sample_format == SAMPLEFORMAT_INT )
1513+ status = SetQuantumFormat (image ,quantum_info ,SignedQuantumFormat );
1514+ if (sample_format == SAMPLEFORMAT_IEEEFP )
1515+ status = SetQuantumFormat (image ,quantum_info ,FloatingPointQuantumFormat );
1516+ if (status == MagickFalse )
1517+ {
1518+ TIFFClose (tiff );
1519+ quantum_info = DestroyQuantumInfo (quantum_info );
1520+ ThrowReaderException (ResourceLimitError ,"MemoryAllocationFailed" );
1521+ }
1522+ status = MagickTrue ;
1523+ switch (photometric )
1524+ {
1525+ case PHOTOMETRIC_MINISBLACK :
1526+ {
1527+ quantum_info -> min_is_white = MagickFalse ;
1528+ break ;
1529+ }
1530+ case PHOTOMETRIC_MINISWHITE :
1531+ {
1532+ quantum_info -> min_is_white = MagickTrue ;
1533+ break ;
1534+ }
1535+ default :
1536+ break ;
1537+ }
1538+ tiff_status = TIFFGetFieldDefaulted (tiff ,TIFFTAG_EXTRASAMPLES ,& extra_samples ,
1539+ & sample_info );
1540+ if (tiff_status == 1 )
1541+ {
1542+ (void ) SetImageProperty (image ,"tiff:alpha" ,"unspecified" ,exception );
1543+ if (extra_samples == 0 )
1544+ {
1545+ if ((samples_per_pixel == 4 ) && (photometric == PHOTOMETRIC_RGB ))
1546+ image -> alpha_trait = BlendPixelTrait ;
1547+ }
1548+ else
1549+ for (i = 0 ; i < extra_samples ; i ++ )
1550+ {
1551+ image -> alpha_trait = BlendPixelTrait ;
1552+ if (sample_info [i ] == EXTRASAMPLE_ASSOCALPHA )
1553+ {
1554+ SetQuantumAlphaType (quantum_info ,DisassociatedQuantumAlpha );
1555+ (void ) SetImageProperty (image ,"tiff:alpha" ,"associated" ,
1556+ exception );
1557+ }
1558+ else
1559+ if (sample_info [i ] == EXTRASAMPLE_UNASSALPHA )
1560+ (void ) SetImageProperty (image ,"tiff:alpha" ,"unassociated" ,
1561+ exception );
1562+ }
1563+ }
15661564 method = ReadGenericMethod ;
15671565 if (TIFFGetField (tiff ,TIFFTAG_ROWSPERSTRIP ,& rows_per_strip ) == 1 )
15681566 {
@@ -2072,7 +2070,8 @@ RestoreMSCWarning
20722070 }
20732071 SetQuantumImageType (image ,quantum_type );
20742072 next_tiff_frame :
2075- quantum_info = DestroyQuantumInfo (quantum_info );
2073+ if (quantum_info != (QuantumInfo * ) NULL )
2074+ quantum_info = DestroyQuantumInfo (quantum_info );
20762075 if (photometric == PHOTOMETRIC_CIELAB )
20772076 DecodeLabImage (image ,exception );
20782077 if ((photometric == PHOTOMETRIC_LOGL ) ||
0 commit comments