ascii: Avoid assertion failure on width underflow in text_draw().
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 19 Apr 2024 16:46:05 +0000 (09:46 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 19 Apr 2024 16:46:19 +0000 (09:46 -0700)
Thanks to Zhou Geng for reporting this bug as poc33 in the report here:
https://lists.gnu.org/archive/html/bug-gnu-pspp/2024-03/msg00015.html

src/output/ascii.c

index d581675fe37d99bf7f63cfb6d2332b9c0b5b1b3e..2676792b8da6bae07ef5f019321baf4c959080e0 100644 (file)
@@ -827,6 +827,11 @@ text_draw (struct ascii_driver *a, enum table_halign halign, bool numeric,
           width -= w;
         }
     }
+  if (width >= SIZE_MAX / 2)
+    {
+      /* Width underflow. */
+      return;
+    }
   if (n == 0)
     return;