From: Douglas Bagnall Date: Fri, 3 May 2019 04:15:30 +0000 (+1200) Subject: lib/texpect: avoid theoretical NULL dereference (CID 1273099) X-Git-Tag: tdb-1.4.1~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c01ff465bcdf34cbd4a090c810764e5227a2abe;p=thirdparty%2Fsamba.git lib/texpect: avoid theoretical NULL dereference (CID 1273099) Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- diff --git a/lib/texpect/texpect.c b/lib/texpect/texpect.c index 3f6278bbb10..8ced5638c67 100644 --- a/lib/texpect/texpect.c +++ b/lib/texpect/texpect.c @@ -424,6 +424,11 @@ int main(int argc, const char **argv) instruction_file = poptGetArg(pc); args = poptGetArgs(pc); + if (args == NULL) { + poptPrintHelp(pc, stderr, 0); + return 1; + } + program_args = (char * const *)discard_const_p(char *, args); program = program_args[0]; @@ -432,7 +437,7 @@ int main(int argc, const char **argv) printf("Using instruction_file: %s\n", instruction_file); printf("Executing '%s' ", program); - for (i = 0; program_args && program_args[i] != NULL; i++) { + for (i = 0; program_args[i] != NULL; i++) { printf("'%s' ", program_args[i]); } printf("\n");