]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix image-cache-size crash
authorLars Ingebrigtsen <larsi@gnus.org>
Fri, 11 Dec 2020 20:16:04 +0000 (21:16 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Fri, 11 Dec 2020 20:16:08 +0000 (21:16 +0100)
* src/image.c (image_frame_cache_size): Ensure that img->pixmap is
in use before trying to access it.

src/image.c

index 8607b33a7a86b861ad85e9240f2a50987f1e5343..0dd108a96b50ac0bb9bffb3003e672720f578450 100644 (file)
@@ -1795,8 +1795,9 @@ which is then usually a filename.  */)
 static int
 image_frame_cache_size (struct frame *f)
 {
-  struct image_cache *c = FRAME_IMAGE_CACHE (f);
   int total = 0;
+#ifdef USE_CAIRO
+  struct image_cache *c = FRAME_IMAGE_CACHE (f);
 
   if (!c)
     return 0;
@@ -1805,12 +1806,11 @@ image_frame_cache_size (struct frame *f)
     {
       struct image *img = c->images[i];
 
-#ifdef USE_CAIRO
-      if (img)
+      if (img && img->pixmap && img->pixmap != NO_PIXMAP)
        total += img->pixmap->width * img->pixmap->height  *
          img->pixmap->bits_per_pixel / 8;
-#endif
     }
+#endif
   return total;
 }