Hard to hit. Nevertheless it seems better to error out than to
crash in strcmp()

Index: seq.c
===================================================================
RCS file: /cvs/src/usr.bin/seq/seq.c,v
retrieving revision 1.3
diff -u -p -r1.3 seq.c
--- seq.c       22 Feb 2022 16:14:38 -0000      1.3
+++ seq.c       22 Feb 2022 16:23:08 -0000
@@ -195,8 +195,9 @@ main(int argc, char *argv[])
         * loop held true due to a rounding error and we still need to print
         * 'last'.
         */
-       asprintf(&cur_print, fmt, cur);
-       asprintf(&last_print, fmt, last);
+       if (asprintf(&cur_print, fmt, cur) == -1 ||
+           asprintf(&last_print, fmt, last) == -1)
+               err(1, "asprintf");
        if (strcmp(cur_print, last_print) == 0 && cur != last_shown_value) {
                if (cur != first)
                    fputs(sep, stdout);

Reply via email to