Blame SOURCES/0006-fix-src-dmierror.c-55-9-warning-Wanalyzer-possible-n.patch

b52212
From fa5f62272997ea5b402ce28c2b197afe1a3c9422 Mon Sep 17 00:00:00 2001
b52212
From: Coiby Xu <coiby.xu@gmail.com>
b52212
Date: Tue, 15 Jun 2021 10:57:45 +0800
b52212
Subject: [PATCH 6/8] fix "src/dmierror.c:55:9:
b52212
 warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL buf where
b52212
 non-null expected"
b52212
b52212
Fix the following error found by covscan,
b52212
    python-dmidecode-3.12.2/src/dmierror.c:55:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL buf where non-null expected
b52212
    /usr/include/python3.9/Python.h:30: included_from: Included from here.
b52212
    python-dmidecode-3.12.2/src/dmierror.c:32: included_from: Included from here.
b52212
    /usr/include/string.h:61:14: note: argument 1 of memset must be non-null
b52212
    #   53|           va_start(ap, fmt);
b52212
    #   54|           buf = (char *) malloc(4098);
b52212
    #   55|->         memset(buf, 0, 4098);
b52212
    #   56|
b52212
    #   57|           if( buf == NULL ) {
b52212
b52212
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
b52212
---
b52212
 src/dmierror.c | 2 +-
b52212
 1 file changed, 1 insertion(+), 1 deletion(-)
b52212
b52212
diff --git a/src/dmierror.c b/src/dmierror.c
b52212
index d64b4b9..7054cd8 100644
b52212
--- a/src/dmierror.c
b52212
+++ b/src/dmierror.c
b52212
@@ -52,7 +52,6 @@ void _pyReturnError(void *exception, const char *fname, int line, const char *fm
b52212
 
b52212
         va_start(ap, fmt);
b52212
         buf = (char *) malloc(4098);
b52212
-        memset(buf, 0, 4098);
b52212
 
b52212
         if( buf == NULL ) {
b52212
                 // Backup routine if we can't get the needed memory
b52212
@@ -64,6 +63,7 @@ void _pyReturnError(void *exception, const char *fname, int line, const char *fm
b52212
                 return;
b52212
         }
b52212
 
b52212
+        memset(buf, 0, 4098);
b52212
         // Set the error state and message
b52212
         snprintf(buf, 4096, "[%s:%i] %s", fname, line, fmt);
b52212
         PyErr_Format(exception, buf, ap);
b52212
-- 
b52212
2.31.1
b52212