You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
python-dmidecode/SOURCES/0006-fix-src-dmierror.c-55-...

47 lines
1.7 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

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