This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 78a6d07a9 nshlib/nsh_consolemain: detect null pointer
78a6d07a9 is described below

commit 78a6d07a9008ba6574da82f04cc961989cd23e8f
Author: Niklas Hauser <[email protected]>
AuthorDate: Mon Aug 28 13:43:54 2023 +0200

    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 */
 

Reply via email to