Commit 942e86ff4 for imagemagick.org

commit 942e86ff479a331ff78ad423977e5bc95a57b8dd
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Fri Oct 30 14:11:42 2026 -0400

    https://github.com/ImageMagick/ImageMagick/issues/9077

diff --git a/coders/mat.c b/coders/mat.c
index a833fb679..c7d90e39f 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -1506,7 +1506,7 @@ END_OF_READING:
     /*
       Rewind list, removing any empty images while rewinding.
     */
-    p=image;
+    p=GetLastImageInList(image);
     image=NULL;
     while (p != (Image *) NULL)
       {