From 6c01ff465bcdf34cbd4a090c810764e5227a2abe Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Fri, 3 May 2019 16:15:30 +1200 Subject: lib/texpect: avoid theoretical NULL dereference (CID 1273099) Signed-off-by: Douglas Bagnall Reviewed-by: Gary Lockyer --- lib/texpect/texpect.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/texpect') 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"); -- cgit v1.2.1