File djvulibre-CVE-2025-53367.patch of Package djvulibre.39595

--- a/libdjvu/MMRDecoder.cpp
+++ b/libdjvu/MMRDecoder.cpp
@@ -589,6 +589,9 @@
   int a0,rle,b1;
   for(a0=0,rle=0,b1=*pr++;a0 < width;)
     {
+      // Check for buffer overflow
+      if (xr > lineruns+width+2 || pr > prevruns+width+2)
+	G_THROW(invalid_mmr_data);
       // Process MMR codes
       const int c=mrtable->decode(src);
       switch ( c )
@@ -714,7 +717,7 @@
                         rle++;
                         a0++;
                       }
-                    if (a0 > width)
+                    if (a0 > width || xr > lineruns+width+2)
                       G_THROW(invalid_mmr_data);
                   }
                 // Analyze uncompressed termination code.
openSUSE Build Service is sponsored by