arg.h: fixed argv checks order
authorLucas Gabriel Vuotto <l.vuotto92@gmail.com>
Mon, 22 Feb 2016 14:03:36 +0000 (11:03 -0300)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 22 Feb 2016 23:31:03 +0000 (00:31 +0100)
This prevents accessing to a potentially out-of-bounds memory section.

Signed-off-by: Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
arg.h

diff --git a/arg.h b/arg.h
index ff1fd13..e94e02b 100644 (file)
--- a/arg.h
+++ b/arg.h
@@ -10,8 +10,8 @@ extern char *argv0;
 
 /* use main(int argc, char *argv[]) */
 #define ARGBEGIN       for (argv0 = *argv, argv++, argc--;\
-                                       argv[0] && argv[0][1]\
-                                       && argv[0][0] == '-';\
+                                       argv[0] && argv[0][0] == '-'\
+                                       && argv[0][1];\
                                        argc--, argv++) {\
                                char argc_;\
                                char **argv_;\