From 78a6d07a9008ba6574da82f04cc961989cd23e8f Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Mon, 28 Aug 2023 13:43:54 +0200 Subject: [PATCH] nshlib/nsh_consolemain: detect null pointer Returning with an error from nsh_consolemain prevents dereferencing a NULL pointer later in the code. --- nshlib/nsh_consolemain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nshlib/nsh_consolemain.c b/nshlib/nsh_consolemain.c index 8590d0284..23c650d87 100644 --- a/nshlib/nsh_consolemain.c +++ b/nshlib/nsh_consolemain.c @@ -65,6 +65,10 @@ int nsh_consolemain(int argc, FAR char *argv[]) int ret; DEBUGASSERT(pstate != NULL); + if (pstate == NULL) + { + return -ENOMEM; + } /* Execute the session */