Commit 47a803cc1 for imagemagick.org

commit 47a803cc139a6eebf14fca5f1d5dd25c7782cc98
Author: Dirk Lemstra <dirk@lemstra.org>
Date:   Sat Feb 28 11:03:09 2026 +0100

    Added checks for overflows.

diff --git a/coders/sixel.c b/coders/sixel.c
index a9ccd8a67..d3a77aff2 100644
--- a/coders/sixel.c
+++ b/coders/sixel.c
@@ -553,7 +553,7 @@ static MagickBooleanType sixel_decode(Image *image,unsigned char *p,
                     {
                       offset=(ssize_t) (imsx*((ssize_t) position_y+i)+
                         (ssize_t) position_x);
-                      if (offset >= (imsx*imsy))
+                      if ((offset < 0) || (offset >= (imsx*imsy)))
                         {
                           imbuf=(sixel_pixel_t *) RelinquishMagickMemory(imbuf);
                           return(MagickFalse);
@@ -584,7 +584,7 @@ static MagickBooleanType sixel_decode(Image *image,unsigned char *p,
                       for (y = position_y + i; y < position_y + i + n; ++y)
                       {
                         offset=(imsx*y+position_x);
-                        if ((offset+repeat_count) >= (imsx*imsy))
+                        if ((offset < 0) || ((offset+repeat_count) >= (imsx*imsy)))
                           {
                             imbuf=(sixel_pixel_t *)
                               RelinquishMagickMemory(imbuf);