about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/HISTORY3
-rw-r--r--lib/libpbm3.c5
2 files changed, 6 insertions, 2 deletions
diff --git a/doc/HISTORY b/doc/HISTORY
index 36845eda..78d167c5 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -39,6 +39,9 @@ not yet  BJH  Release 10.38.0
 
               libnetpbm: fix buffer overrun with PBM images < 8 columns.
 
+              libnetpbm: fix crash with PBM images < 8 columns on MMX/SSE
+              machine.
+
               pamtogif: fail properly if image to wide or high for GIF.
 
               ppmdraw: fix crash with use of freed storage.  Thanks
diff --git a/lib/libpbm3.c b/lib/libpbm3.c
index a3ada015..2a811748 100644
--- a/lib/libpbm3.c
+++ b/lib/libpbm3.c
@@ -107,11 +107,12 @@ packBitsWithMmxSse(FILE *          const fileP,
 
     typedef int v8qi __attribute__ ((mode(V8QI)));
     typedef int di __attribute__ ((mode(DI)));
-    int col;
 
     di const zero64 = 0;        /* to clear with PXOR */
 
-    for (col = 0; col < cols-7; col += 8) {
+    unsigned int col;
+
+    for (col = 0; col + 7 < cols; col += 8) {
         v8qi const compare =
             __builtin_ia32_pcmpeqb(*(v8qi*) (&bitrow[col]), *(v8qi*) &zero64);
         unsigned char const backwardWhiteMask = (unsigned char)