]> diplodocus.org Git - nmh/commitdiff
anno: Stop segmentation violation on `-number 0'.
authorRalph Corderoy <ralph@inputplus.co.uk>
Tue, 1 Nov 2016 00:05:42 +0000 (00:05 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Tue, 1 Nov 2016 00:18:36 +0000 (00:18 +0000)
If atoi(3) returned zero, either because `0' was given or the number
could not be parsed, then the error message dereferenced an invalid
pointer.  Found when trying to increase coverage with check_exit.

uip/anno.c

index 5376930..c6446fc 100644 (file)
@@ -169,7 +169,7 @@ main (int argc, char **argv)
                            number = -1;
 
                        else if (!(number = atoi(*argp)))
                            number = -1;
 
                        else if (!(number = atoi(*argp)))
-                           adios (NULL, "missing argument to %s", argp[-2]);
+                           adios (NULL, "missing argument to %s", argp[-1]);
 
                        argp++;
                    }
 
                        argp++;
                    }