From 6db8529a785e2cab142e840b6e3fbdcc2c02dd1f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 19 Dec 2013 21:38:12 -0600 Subject: Don't permute toys.optargs, cleanup code (xexec()) can free it. --- toys/other/hello.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'toys/other/hello.c') diff --git a/toys/other/hello.c b/toys/other/hello.c index e87cd6c9..eb80972e 100644 --- a/toys/other/hello.c +++ b/toys/other/hello.c @@ -41,6 +41,8 @@ GLOBALS( void hello_main(void) { + char **optargs; + printf("Hello world\n"); if (toys.optflags) printf("flags=%x\n", toys.optflags); @@ -52,7 +54,8 @@ void hello_main(void) TT.d_list = TT.d_list->next; } if (TT.e_count) printf("e was seen %ld times\n", TT.e_count); - while (*toys.optargs) printf("optarg=%s\n", *(toys.optargs++)); + for (optargs = toys.optargs; *optargs; optargs++) + printf("optarg=%s\n", *optargs); if (toys.optflags & FLAG_walrus) printf("Saw --walrus\n"); if (TT.blubber_string) printf("--blubber=%s\n", TT.blubber_string); } -- cgit v1.2.3