summaryrefslogtreecommitdiff
path: root/tests/test-ptrace.c
diff options
context:
space:
mode:
authorArun Sharma <asharma@fb.com>2012-08-04 18:01:46 -0700
committerArun Sharma <asharma@fb.com>2012-08-04 18:06:07 -0700
commit707b1dba99323c80ed9730870f6eab949f5b9b98 (patch)
treeb6b1a60288a0e83cc2eedd4124f6afed72df5e28 /tests/test-ptrace.c
parent32202619c42f58a9dac6eee3b9a4c231f1ce394a (diff)
downloadlibunwind-707b1dba99323c80ed9730870f6eab949f5b9b98.tar.gz
Fix a SIGSEGV in test-ptrace.c
./test-ptrace -v resulted in a SIGSEGV.
Diffstat (limited to 'tests/test-ptrace.c')
-rw-r--r--tests/test-ptrace.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test-ptrace.c b/tests/test-ptrace.c
index c9f8f2e9..8f2e1cb1 100644
--- a/tests/test-ptrace.c
+++ b/tests/test-ptrace.c
@@ -204,6 +204,8 @@ main (int argc, char **argv)
++optind, print_names = 0;
else
fprintf(stderr, "unrecognized option: %s\n", argv[optind++]);
+ if (optind >= argc)
+ break;
}
target_pid = fork ();
@@ -221,6 +223,11 @@ main (int argc, char **argv)
#else
#error Trace me
#endif
+
+ if (optind == argc) {
+ fprintf(stderr, "Need to specify a command line for the child\n");
+ exit (-1);
+ }
execve (argv[optind], argv + optind, environ);
_exit (-1);
}