nima / python-dmidecode

Python DMI-Decode
39 stars 27 forks source link

Fix bogus invocation of _pyReturnError() in __dmidecode_xml_getsection() #57

Open glaubitz opened 5 months ago

glaubitz commented 5 months ago

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); ^~
DuratarskeyK commented 4 months ago

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.

glaubitz commented 4 months ago

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.

DuratarskeyK commented 4 months ago

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

glaubitz commented 4 months ago

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.

DuratarskeyK commented 4 months ago

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