I’m finding that certain (possibly corrupt) TIFF images will crash my app, with the following stack trace:
Application Specific Information:
Assertion failed: (0), function img_data_depth, file /System/Volumes/Data/SWE/macOS/BuildRoots/d7e177bcf5/Library/Caches/com.apple.xbs/Sources/CoreGraphics/CoreGraphics-1463.16.1/CoreGraphics/Images/CGSImage.c, line 4539.
Thread 4 Crashed:
0 libsystem_kernel.dylib 0x00007fff2049592e __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff204c45bd pthread_kill + 263
2 libsystem_c.dylib 0x00007fff20419406 abort + 125
3 libsystem_c.dylib 0x00007fff204187d8 __assert_rtn + 314
4 com.apple.CoreGraphics 0x00007fff25518179 img_data_depth.cold.2 + 54
5 com.apple.CoreGraphics 0x00007fff2536493c img_data_depth + 1211
6 com.apple.CoreGraphics 0x00007fff25106a0b img_data_lock + 6275
7 com.apple.CoreGraphics 0x00007fff251016d0 CGSImageDataLock + 1230
8 com.apple.CoreGraphics 0x00007fff2510099f ripc_AcquireRIPImageData + 459
9 com.apple.CoreGraphics 0x00007fff250ff681 ripc_DrawImage + 1180
10 com.apple.CoreGraphics 0x00007fff250fe8d7 CGContextDrawImageWithOptions + 454
11 com.apple.AppKit 0x00007fff22f31045 __74-[NSImageRep drawInRect:fromRect:operation:fraction:respectFlipped:hints:]_block_invoke + 902
12 com.apple.AppKit 0x00007fff22f30b7a -[NSImageRep drawInRect:fromRect:operation:fraction:respectFlipped:hints:] + 936
13 XojoFramework.dylib 0x000000011038ad1d DrawableCocoaBitmap::CreateMaskFromAlpha() + 349
14 XojoFramework.dylib 0x0000000110464f35 Drawable::CopyMask() + 45
15 XojoFramework.dylib 0x00000001104cc63a PictureCopyMask + 236
Is there any way to trap this kind of error so it doesn’t terminate the app?