[hackers] [sbase] Fix potential modulo 0 || FRIGN

From: <git_AT_suckless.org>
Date: Sun, 1 Feb 2015 02:30:47 +0100 (CET)

commit e2010b08fdd56ecc91eafc3a91a5ef40d234231d
Author: FRIGN <dev_AT_frign.de>
Date: Sun Feb 1 02:23:35 2015 +0100

    Fix potential modulo 0

diff --git a/yes.c b/yes.c
index fe9af7f..c3f2314 100644
--- a/yes.c
+++ b/yes.c
_AT_@ -20,8 +20,11 @@ main(int argc, char *argv[])
                 usage();
         } ARGEND;
 
- for (i = 0; ;i++, i %= argc) {
- printf("%s", (argc > 0) ? argv[i] : "y");
+ if (argc == 0)
+ for (;;)
+ puts("y");
+ for (i = 0; ; i++, i %= argc) {
+ printf("%s", argv[i]);
                 putchar((i == argc - 1) ? '\n' : ' ');
         }
         return 1; /* should not reach */
Received on Sun Feb 01 2015 - 02:30:47 CET

This archive was generated by hypermail 2.3.0 : Sun Feb 01 2015 - 02:36:10 CET