From 34f31ff3f8a5ec33a4766c5c0e30d602eb14402e Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 16 Jun 2021 01:38:07 +0800 Subject: [PATCH] binfmt: Handle argv/argv[0] == NULL correctly in exec_module Signed-off-by: Xiang Xiao --- binfmt/binfmt_execmodule.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/binfmt/binfmt_execmodule.c b/binfmt/binfmt_execmodule.c index 41002482f1..503de245c3 100644 --- a/binfmt/binfmt_execmodule.c +++ b/binfmt/binfmt_execmodule.c @@ -168,8 +168,17 @@ int exec_module(FAR const struct binary_s *binp, /* Initialize the task */ - ret = nxtask_init(tcb, argv[0], binp->priority, NULL, - binp->stacksize, binp->entrypt, &argv[1]); + if (argv && argv[0]) + { + ret = nxtask_init(tcb, argv[0], binp->priority, NULL, + binp->stacksize, binp->entrypt, &argv[1]); + } + else + { + ret = nxtask_init(tcb, filename, binp->priority, NULL, + binp->stacksize, binp->entrypt, argv); + } + binfmt_freeargv(argv); if (ret < 0) {