From 707b1dba99323c80ed9730870f6eab949f5b9b98 Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Sat, 4 Aug 2012 18:01:46 -0700 Subject: [PATCH] Fix a SIGSEGV in test-ptrace.c ./test-ptrace -v resulted in a SIGSEGV. --- tests/test-ptrace.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); }