Skip to content

Commit aa2c20e

Browse files
author
David Sommerseth
committed
RETURN_STRING() did not use Py_INCREF() when returning Py_None
From RH BZ#680269: #define RETURN_STRING(str) (str ? PyString_FromString(str) : Py_None) This isn't incrementing the reference count on the Py_None singleton when it should be (the caller assumes that it "owns" a ref on the result of _getter, and will decref it), it could cause the python process to bail out: "Fatal Python error: deallocating None" if run repeatedly. Reported-by: Dave Malcolm <dmalcolm@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
1 parent 08133e0 commit aa2c20e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

python-ethtool/etherinfo_struct.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ typedef struct {
8787
*
8888
* @return Returns a PyObject with either the input string wrapped up, or a Python None value.
8989
*/
90-
#define RETURN_STRING(str) (str ? PyString_FromString(str) : Py_None)
90+
#define RETURN_STRING(str) (str ? PyString_FromString(str) : (Py_INCREF(Py_None), Py_None))
9191

9292
#endif

0 commit comments

Comments
 (0)