Skip to content

Commit 17e01f3

Browse files
committed
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 ) {
1 parent 70be832 commit 17e01f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/dmierror.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ void _pyReturnError(void *exception, const char *fname, int line, const char *fm
5252

5353
va_start(ap, fmt);
5454
buf = (char *) malloc(4098);
55-
memset(buf, 0, 4098);
5655

5756
if( buf == NULL ) {
5857
// 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
6463
return;
6564
}
6665

66+
memset(buf, 0, 4098);
6767
// Set the error state and message
6868
snprintf(buf, 4096, "[%s:%i] %s", fname, line, fmt);
6969
PyErr_Format(exception, buf, ap);

0 commit comments

Comments
 (0)