File ImageMagick-CVE-2026-25983.patch of Package ImageMagick.42997

From b4f8e1a387dd1d0a0af516071831a235f2fdf437 Mon Sep 17 00:00:00 2001
From: Dirk Lemstra <dirk@lemstra.org>
Date: Sun, 25 Jan 2026 18:49:10 +0100
Subject: [PATCH] No longer allow mutations on the first image of the list
 (GHSA-fwqw-2x5x-w566)

---
 coders/msl.c | 150 +++++++++++++++++++++++++--------------------------
 1 file changed, 75 insertions(+), 75 deletions(-)

Index: ImageMagick-7.1.1-21/coders/msl.c
===================================================================
--- ImageMagick-7.1.1-21.orig/coders/msl.c
+++ ImageMagick-7.1.1-21/coders/msl.c
@@ -698,7 +698,7 @@ static void MSLStartElement(void *contex
           /*
             Add noise image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || ((n < 1) || (msl_info->image[n] == (Image *) NULL)))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -774,7 +774,7 @@ static void MSLStartElement(void *contex
           /*
             Annotate image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1109,7 +1109,7 @@ static void MSLStartElement(void *contex
           MagickBooleanType
             stack;
 
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1167,7 +1167,7 @@ static void MSLStartElement(void *contex
           /*
             Adjusts an image's orientation
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1197,7 +1197,7 @@ static void MSLStartElement(void *contex
           /*
             Blur image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1293,7 +1293,7 @@ static void MSLStartElement(void *contex
           /*
             Border image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1415,7 +1415,7 @@ static void MSLStartElement(void *contex
           /*
             Add noise image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1480,7 +1480,7 @@ static void MSLStartElement(void *contex
             radius = 0.0,
             sigma = 1.0;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -1555,7 +1555,7 @@ static void MSLStartElement(void *contex
           /*
             Chop image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1662,7 +1662,7 @@ static void MSLStartElement(void *contex
           /*
             Color floodfill image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -1794,7 +1794,7 @@ static void MSLStartElement(void *contex
           /*
             Composite image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2137,7 +2137,7 @@ static void MSLStartElement(void *contex
           /*
             Contrast image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2191,7 +2191,7 @@ static void MSLStartElement(void *contex
           /*
             Crop image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2293,7 +2293,7 @@ static void MSLStartElement(void *contex
           /*
             Cycle-colormap image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2347,7 +2347,7 @@ static void MSLStartElement(void *contex
           /*
             Despeckle image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2373,7 +2373,7 @@ static void MSLStartElement(void *contex
         }
       if (LocaleCompare((const char *) tag,"display") == 0)
         {
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2401,7 +2401,7 @@ static void MSLStartElement(void *contex
           /*
             Annotate image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2764,7 +2764,7 @@ static void MSLStartElement(void *contex
           /*
             Edge image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2830,7 +2830,7 @@ static void MSLStartElement(void *contex
           /*
             Emboss image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2909,7 +2909,7 @@ static void MSLStartElement(void *contex
           /*
             Enhance image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2938,7 +2938,7 @@ static void MSLStartElement(void *contex
           /*
             Equalize image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -2966,7 +2966,7 @@ static void MSLStartElement(void *contex
     {
       if (LocaleCompare((const char *) tag, "flatten") == 0)
       {
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -2997,7 +2997,7 @@ static void MSLStartElement(void *contex
           /*
             Flip image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3029,7 +3029,7 @@ static void MSLStartElement(void *contex
           /*
             Flop image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3064,7 +3064,7 @@ static void MSLStartElement(void *contex
           /*
             Frame image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3218,7 +3218,7 @@ static void MSLStartElement(void *contex
           /*
             Gamma image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3313,7 +3313,7 @@ static void MSLStartElement(void *contex
         }
       else if (LocaleCompare((const char *) tag,"get") == 0)
         {
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3447,7 +3447,7 @@ static void MSLStartElement(void *contex
           /*
             Implode image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3519,7 +3519,7 @@ static void MSLStartElement(void *contex
         double
           levelBlack = 0, levelGamma = 1, levelWhite = QuantumRange;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -3594,7 +3594,7 @@ static void MSLStartElement(void *contex
           /*
             Magnify image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3632,7 +3632,7 @@ static void MSLStartElement(void *contex
           /*
             Map image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3723,7 +3723,7 @@ static void MSLStartElement(void *contex
             Matte floodfill image.
           */
           opacity=0.0;
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3855,7 +3855,7 @@ static void MSLStartElement(void *contex
           /*
             Median-filter image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3923,7 +3923,7 @@ static void MSLStartElement(void *contex
           /*
             Minify image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -3957,7 +3957,7 @@ static void MSLStartElement(void *contex
           /*
             Modulate image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4087,7 +4087,7 @@ static void MSLStartElement(void *contex
           /*
             Negate image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4156,7 +4156,7 @@ static void MSLStartElement(void *contex
           /*
             Normalize image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4214,7 +4214,7 @@ static void MSLStartElement(void *contex
           /*
             Oil-paint image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4282,7 +4282,7 @@ static void MSLStartElement(void *contex
           /*
             Opaque image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4392,7 +4392,7 @@ static void MSLStartElement(void *contex
         }
         if (LocaleCompare((const char *) tag, "profile") == 0)
           {
-            if (msl_info->image[n] == (Image *) NULL)
+            if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
               {
                 ThrowMSLException(OptionError,"NoImagesDefined",
                   (const char *) tag);
@@ -4506,7 +4506,7 @@ static void MSLStartElement(void *contex
           /*
             Quantize image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -4985,7 +4985,7 @@ static void MSLStartElement(void *contex
           /*
             Raise image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5123,7 +5123,7 @@ static void MSLStartElement(void *contex
           /*
             Reduce-noise image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5185,18 +5185,17 @@ static void MSLStartElement(void *contex
         }
       else if (LocaleCompare((const char *) tag,"repage") == 0)
       {
-        /* init the values */
-        width=msl_info->image[n]->page.width;
-        height=msl_info->image[n]->page.height;
-        x=msl_info->image[n]->page.x;
-        y=msl_info->image[n]->page.y;
-
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
           break;
         }
+        /* init the values */
+        width=msl_info->image[n]->page.width;
+        height=msl_info->image[n]->page.height;
+        x=msl_info->image[n]->page.x;
+        y=msl_info->image[n]->page.y;
         if (attributes == (const xmlChar **) NULL)
           break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
@@ -5317,7 +5316,7 @@ static void MSLStartElement(void *contex
         x_resolution,
         y_resolution;
 
-      if (msl_info->image[n] == (Image *) NULL)
+      if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -5419,7 +5418,7 @@ static void MSLStartElement(void *contex
           /*
             Resize image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5514,7 +5513,7 @@ static void MSLStartElement(void *contex
           /*
             Roll image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5588,19 +5587,18 @@ static void MSLStartElement(void *contex
         }
       else if (LocaleCompare((const char *) tag,"roll") == 0)
       {
-        /* init the values */
-        width=msl_info->image[n]->columns;
-        height=msl_info->image[n]->rows;
-        x = y = 0;
-
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
           break;
         }
+        /* init the values */
+        width=msl_info->image[n]->columns;
+        height=msl_info->image[n]->rows;
+        x = y = 0;
         if (attributes == (const xmlChar **) NULL)
-        break;
+          break;
         for (i=0; (attributes[i] != (const xmlChar *) NULL); i++)
         {
           keyword=(const char *) attributes[i++];
@@ -5675,7 +5673,7 @@ static void MSLStartElement(void *contex
           /*
             Rotate image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5739,7 +5737,7 @@ static void MSLStartElement(void *contex
         /* init the values */
         double  degrees = 0;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -5805,7 +5803,7 @@ static void MSLStartElement(void *contex
           /*
             Sample image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5882,7 +5880,7 @@ static void MSLStartElement(void *contex
           /*
             Scale image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -5962,7 +5960,7 @@ static void MSLStartElement(void *contex
           /*
             Segment image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6046,7 +6044,7 @@ static void MSLStartElement(void *contex
         }
       else if (LocaleCompare((const char *) tag, "set") == 0)
       {
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
           break;
@@ -6221,7 +6219,7 @@ static void MSLStartElement(void *contex
           /*
             Shade image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6312,7 +6310,7 @@ static void MSLStartElement(void *contex
           /*
             Shear image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6412,7 +6410,7 @@ static void MSLStartElement(void *contex
             radius = 0.0,
             sigma = 1.0;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",
               (const char *) tag);
@@ -6485,7 +6483,7 @@ static void MSLStartElement(void *contex
         width = height = 0;
         x = y = 0;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
         {
           ThrowMSLException(OptionError,"NoImagesDefined",
             (const char *) tag);
@@ -6576,7 +6574,7 @@ static void MSLStartElement(void *contex
           /*
             Shear image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6665,7 +6663,7 @@ static void MSLStartElement(void *contex
           /*
             Signature image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6689,7 +6687,7 @@ static void MSLStartElement(void *contex
           /*
             Solarize image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6751,7 +6749,7 @@ static void MSLStartElement(void *contex
           /*
             Spread image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6816,7 +6814,7 @@ static void MSLStartElement(void *contex
         Image *
           watermark = (Image*) NULL;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",
               (const char *) tag);
@@ -6884,7 +6882,7 @@ static void MSLStartElement(void *contex
         Image *
           stereoImage = (Image*) NULL;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
             break;
@@ -6951,7 +6949,7 @@ static void MSLStartElement(void *contex
           /*
             Strip image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -6981,7 +6979,7 @@ static void MSLStartElement(void *contex
             index,
             swap_index;
 
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7047,7 +7045,7 @@ static void MSLStartElement(void *contex
           /*
             Swirl image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7111,7 +7109,7 @@ static void MSLStartElement(void *contex
           /*
             Sync image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7144,7 +7142,7 @@ static void MSLStartElement(void *contex
           /*
             Texture image.
           */
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7199,7 +7197,7 @@ static void MSLStartElement(void *contex
         /* init the values */
         double  threshold = 0;
 
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
             break;
@@ -7244,7 +7242,7 @@ static void MSLStartElement(void *contex
       }
       else if (LocaleCompare((const char *) tag, "transparent") == 0)
       {
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
             break;
@@ -7288,7 +7286,7 @@ static void MSLStartElement(void *contex
       }
       else if (LocaleCompare((const char *) tag, "trim") == 0)
       {
-        if (msl_info->image[n] == (Image *) NULL)
+        if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
           {
             ThrowMSLException(OptionError,"NoImagesDefined",(const char *) tag);
             break;
@@ -7323,7 +7321,7 @@ static void MSLStartElement(void *contex
     {
       if (LocaleCompare((const char *) tag,"write") == 0)
         {
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7415,7 +7413,7 @@ static void MSLEndElement(void *context,
     {
       if (LocaleCompare((const char *) tag,"comment") == 0 )
         {
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
@@ -7470,7 +7468,7 @@ static void MSLEndElement(void *context,
     {
       if (LocaleCompare((const char *) tag,"label") == 0 )
         {
-          if (msl_info->image[n] == (Image *) NULL)
+          if ((n < 1) || (msl_info->image[n] == (Image *) NULL))
             {
               ThrowMSLException(OptionError,"NoImagesDefined",
                 (const char *) tag);
openSUSE Build Service is sponsored by