]> diplodocus.org Git - nmh/blobdiff - sbr/base64.c
Fix invalid pointer arithmetic.
[nmh] / sbr / base64.c
index f24e9fe28b7e46ff4116ede3d74c3524a63dc742..cbd225dee062c60fa42ebb8415350bc17cb4f835 100644 (file)
@@ -324,12 +324,9 @@ test_end:
     }
 
     if (! self_delimiting  &&  bitno != 18) {
-        int i;
-
         /* Show some context for the error. */
-        for (i = 0; i < 20  &&  cp > encoded; ++i, --cp) {}
-        inform("premature ending (bitno %d) near %s", bitno,
-                cp ? cp : encoded);
+        cp -= min(cp - encoded, 20);
+        inform("premature ending (bitno %d) near %s", bitno, cp);
         charstring_free (decoded_c);
         *decoded = NULL;