Xinqi Bao's Git

arg.h: fixed argv checks order
authorLucas Gabriel Vuotto <[email protected]>
Fri, 19 Feb 2016 18:59:49 +0000 (15:59 -0300)
committerChristoph Lohmann <[email protected]>
Sun, 21 Feb 2016 16:21:41 +0000 (17:21 +0100)
This prevents accessing to a potentially out-of-bounds memory section.

Signed-off-by: Lucas Gabriel Vuotto <[email protected]>
Signed-off-by: Christoph Lohmann <[email protected]>
arg.h

diff --git a/arg.h b/arg.h
index a94e6b5..ba3fb3f 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_;\