summaryrefslogtreecommitdiff
path: root/lib/texpect
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2019-05-03 16:15:30 +1200
committerDouglas Bagnall <dbagnall@samba.org>2019-05-09 22:39:27 +0000
commit6c01ff465bcdf34cbd4a090c810764e5227a2abe (patch)
tree4f8c51303440088e1142dd25b404eccde2b4df02 /lib/texpect
parent9fd3939a718ce051bf006b474bb7cbe1d6f8db3a (diff)
downloadsamba-6c01ff465bcdf34cbd4a090c810764e5227a2abe.tar.gz
lib/texpect: avoid theoretical NULL dereference (CID 1273099)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'lib/texpect')
-rw-r--r--lib/texpect/texpect.c7
1 files changed, 6 insertions, 1 deletions
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");