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

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

commit 44cde372530a9eb5dc990034b66fb5ba908c7799
Author: xuxingliang <[email protected]>
AuthorDate: Wed Dec 3 09:27:17 2025 +0800

    libc/backtrace: check the arguments of backtrace_format()
    
    backtrace_format() used buffer and backtrace without checking them, and
    Coverity reports a possible NULL pointer access through the call in
    sched/misc/assert.c.  Return 0 for a NULL buffer or backtrace, as for a
    size below 1.
    
    Signed-off-by: xuxingliang <[email protected]>
---
 libs/libc/misc/lib_backtrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/libc/misc/lib_backtrace.c b/libs/libc/misc/lib_backtrace.c
index c2ba3887c3f..327f19399cd 100644
--- a/libs/libc/misc/lib_backtrace.c
+++ b/libs/libc/misc/lib_backtrace.c
@@ -472,7 +472,7 @@ int backtrace_format(FAR char *buffer, int size,
   int len = 0;
   int i;
 
-  if (size < 1)
+  if (buffer == NULL || backtrace == NULL || size < 1)
     {
       return 0;
     }

Reply via email to