]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix image crash on macOS (bug#49688)
authorAlan Third <alan@idiocy.org>
Sat, 24 Jul 2021 11:44:19 +0000 (12:44 +0100)
committerAlan Third <alan@idiocy.org>
Mon, 26 Jul 2021 20:04:05 +0000 (21:04 +0100)
* src/nsimage.m ([EmacsImage allocInitFromFile:]): Use isValid to
check whether the image is valid instead of generating a tiff.

src/nsimage.m

index 3c16cd371e652b8770c4a167dd50c41449073285..3668a7ab1077af7ada86dba83d90cb13b7cb74ce 100644 (file)
@@ -265,16 +265,12 @@ ns_image_size_in_bytes (void *img)
   image = [[EmacsImage alloc] initByReferencingFile:filename];
 
   image->bmRep = nil;
-#ifdef NS_IMPL_COCOA
-  imgRep = [NSBitmapImageRep imageRepWithData:[image TIFFRepresentation]];
-#else
-  imgRep = [image bestRepresentationForDevice: nil];
-#endif
-  if (imgRep == nil)
+  if (![image isValid])
     {
       [image release];
       return nil;
     }
+  imgRep = [[image representations] firstObject];
 
   [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
   [image setName:filename];