From 4f81e5942a77b4943b82b0d0d5acd451a113e934 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Fri, 22 Aug 2014 01:09:05 +0000 Subject: [PATCH] Handle null argv in `switch.c` --- src/switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/switch.c b/src/switch.c index df3574d2d7..241c674817 100644 --- a/src/switch.c +++ b/src/switch.c @@ -1053,7 +1053,7 @@ int main(int argc, char *argv[]) setrlimit(RLIMIT_STACK, &rlp); apr_terminate(); - ret = (int) execv(argv[0], argv); + if (argv) ret = (int) execv(argv[0], argv); for (i = 0; i < argc; i++) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s ", argv[i]); @@ -1215,7 +1215,7 @@ int main(int argc, char *argv[]) int j = 0; switch_sleep(1000000); - if (execv(argv[0], argv) == -1) { + if (!argv || execv(argv[0], argv) == -1) { fprintf(stderr, "Restart Failed [%s] resorting to plan b\n", strerror(errno)); for (j = 0; j < argc; j++) { switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s ", argv[j]);