python-dmidecode icon indicating copy to clipboard operation
python-dmidecode copied to clipboard

Fix bogus invocation of _pyReturnError() in __dmidecode_xml_getsection()

Open glaubitz opened this issue 1 year ago • 5 comments

Fixes the following error:

src/dmidecodemodule.c: In function ‘__dmidecode_xml_getsection’: src/dmidecodemodule.c:482:90: error: passing argument 3 of ‘_pyReturnError’ makes integer from pointer without a cast [-Wint-conversion] 482 | _pyReturnError(PyExc_RuntimeError, "Invalid type id '%s' -- %s", typeid, err); | ^~~~~~ | | |

glaubitz avatar Jun 06 '24 10:06 glaubitz

I think they meant to call PyReturnError here. https://github.com/nima/python-dmidecode/blob/master/src/dmierror.h#L48 The signature matches with what's being passed as arguments.

DuratarskeyK avatar Jul 14 '24 13:07 DuratarskeyK

I think they meant to call PyReturnError here. https://github.com/nima/python-dmidecode/blob/master/src/dmierror.h#L48 The signature matches with what's being passed as arguments.

Nope, PyReturnError() is a macro that contains a return instruction and would end the execution __dmidecode_xml_getsection() prematurely so that the following call to free() would be missed.

glaubitz avatar Jul 14 '24 13:07 glaubitz

Right. Well, at least I guess NULL, 0 should become __FILE__, __LINE__

DuratarskeyK avatar Jul 14 '24 15:07 DuratarskeyK

Right. Well, at least I guess NULL, 0 should become FILE, LINE

Those are place holders in the macro and not local variables to the function __dmidecode_xml_getsection.

glaubitz avatar Jul 14 '24 15:07 glaubitz

Those are standard macros that evaluate to file name and line.

hisshadow@uberlaptop ~ $ cat  2.c
__FILE__
__LINE__
hisshadow@uberlaptop ~ $ gcc -E 2.c
# 0 "2.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "2.c"
"2.c"
2

DuratarskeyK avatar Jul 14 '24 20:07 DuratarskeyK