Commit cf973b410 for imagemagick.org

commit cf973b410447fc051aa05fb93573e29762e34981
Author: Cristy <urban-warrior@imagemagick.org>
Date:   Fri Nov 13 20:58:47 2026 -0500

    set jbig maxsize to width/height resource limits

diff --git a/coders/jbig.c b/coders/jbig.c
index 911eecd3f..b5bfb36cc 100644
--- a/coders/jbig.c
+++ b/coders/jbig.c
@@ -62,6 +62,7 @@
 #include "MagickCore/nt-base-private.h"
 #include "MagickCore/pixel-accessor.h"
 #include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
 #include "MagickCore/static.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/string-private.h"
@@ -139,6 +140,10 @@ static Image *ReadJBIGImage(const ImageInfo *image_info,
     byte,
     *p;

+  unsigned long
+    columns,
+    rows;
+
   /*
     Open image file.
   */
@@ -163,8 +168,11 @@ static Image *ReadJBIGImage(const ImageInfo *image_info,
       (image->rows != (unsigned long) image->rows))
     ThrowReaderException(ImageError,"WidthOrHeightExceedsLimit");
   jbg_dec_init(&jbig_info);
-  jbg_dec_maxsize(&jbig_info,(unsigned long) image->columns,(unsigned long)
-    image->rows);
+  columns=(unsigned long) MagickMin(image->columns != 0 ?  image->columns :
+    GetMagickResourceLimit(WidthResource),ULONG_MAX);
+  rows=(unsigned long) MagickMin(image->rows != 0 ?  image->rows :
+    GetMagickResourceLimit(HeightResource),ULONG_MAX);
+  jbg_dec_maxsize(&jbig_info,columns,rows);
   image->columns=jbg_dec_getwidth(&jbig_info);
   image->rows=jbg_dec_getheight(&jbig_info);
   image->depth=8;