Created attachment 2118974 [details] a TIFF file displaying the issue Description of problem: Running identify on the attached TIFF file issues an error : $ identify -format '%k' ./out16_instanceId.tiff identify: Failed to allocate memory for to read TIFF directory (0 elements of 12 bytes each). `./out16_instanceId.tiff' @ error/tiff.c/TIFFErrors/586. identify: Failed to read custom directory at offset 29706. `TIFFReadCustomDirectory' @ error/tiff.c/TIFFErrors/586. 1% GraphicsMagick (from EPEL-9 too) properly returns the expected result : $ /usr/bin/gm identify -format '%k' /disney/shows/soft/QE/images/test/out16_instanceId.tiff 10 Version-Release number of selected component (if applicable): $ identify --version Version: ImageMagick 6.9.13-25 Q16 x86_64 18639 https://legacy.imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP(4.5) Delegates (built-in): bzlib cairo djvu fontconfig freetype gslib gvc jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zlib I am also able to reproduce on a RHEL 10 system with the EPEL-10 build $ identify --version Version: ImageMagick 7.1.1-43 Q16-HDRI x86_64 22550 https://imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC HDRI Modules OpenMP(4.5) Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype gslib gvc heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma openexr pangocairo png ps raqm raw rsvg tiff webp wmf x xml zip zlib zstd Compiler: gcc (14.2) How reproducible: Every time when ran on the attached TIFF. Randomly outputs the expected result on other TIFF files. Steps to Reproduce: 1. download the attached TIFF file 2. run identify on it Actual results: identify: Failed to read custom directory at offset 29706. `TIFFReadCustomDirectory' @ error/tiff.c/TIFFErrors/586. Expected results: 10 Additional info: To the best of my knowledge, this is a valid TIFF file which does not issue any error with another tool.