From d40e5050be2029613bc0ca3e18f9a50d8187ee8e Mon Sep 17 00:00:00 2001 From: Alan Third Date: Sun, 1 Mar 2026 17:57:18 +0000 Subject: [PATCH] Fix seg fault when image dimensions don't match (bug#80518) * src/image.c (four_corners_best): [USE_CAIRO] Reset the image dimensions to real values. (Fimage_transforms_p): Fix typo. --- src/image.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/image.c b/src/image.c index 8dfab77ce43..9d0a620188f 100644 --- a/src/image.c +++ b/src/image.c @@ -1937,6 +1937,14 @@ four_corners_best (Emacs_Pix_Context pimg, int *corners, RGB_PIXEL_COLOR best UNINIT; int i, best_count; +#ifdef USE_CAIRO + /* Sometimes the Cairo codepath calls this function *after* the image + sizes have been modified by native-transforms, so the pimg + dimensions don't match WIDTH and HEIGHT. */ + width = pimg->width; + height = pimg->height; +#endif + if (corners && corners[BOT_CORNER] >= 0) { /* Get the colors at the corner_pixels of pimg. */ @@ -12848,7 +12856,7 @@ The list of capabilities can include one or more of the following: { #ifdef HAVE_NATIVE_TRANSFORMS # if defined HAVE_IMAGEMAGICK || defined (USE_CAIRO) || defined (HAVE_NS) \ - || defined (HAVE_HAIKU) | defined HAVE_ANDROID + || defined (HAVE_HAIKU) || defined HAVE_ANDROID return list2 (Qscale, Qrotate90); # elif defined (HAVE_X_WINDOWS) && defined (HAVE_XRENDER) if (FRAME_DISPLAY_INFO (f)->xrender_supported_p)