diff options
author | David Sommerseth <davids@redhat.com> | 2011-02-25 09:57:04 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2011-02-25 09:57:04 +0100 |
commit | aa2c20e697af1907b92129410aa10952a3ffdd68 (patch) | |
tree | 15fcddb4c82aa1c825d3119e8b5267fab5f60bea | |
parent | 08133e0736fd04a33ce66564b0c95018497e0a35 (diff) | |
download | python-ethtool-aa2c20e697af1907b92129410aa10952a3ffdd68.tar.gz python-ethtool-aa2c20e697af1907b92129410aa10952a3ffdd68.tar.xz python-ethtool-aa2c20e697af1907b92129410aa10952a3ffdd68.zip |
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>
-rw-r--r-- | python-ethtool/etherinfo_struct.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/python-ethtool/etherinfo_struct.h b/python-ethtool/etherinfo_struct.h index b1d453f..3ae037f 100644 --- a/python-ethtool/etherinfo_struct.h +++ b/python-ethtool/etherinfo_struct.h @@ -87,6 +87,6 @@ typedef struct { * * @return Returns a PyObject with either the input string wrapped up, or a Python None value. */ -#define RETURN_STRING(str) (str ? PyString_FromString(str) : Py_None) +#define RETURN_STRING(str) (str ? PyString_FromString(str) : (Py_INCREF(Py_None), Py_None)) #endif |