summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-03-01 13:10:43 +0100
committerChristian Tismer <tismer@stackless.com>2019-03-01 12:41:19 +0000
commit8aa9cdf783e926e9d9a5543b77a54d3a34e90782 (patch)
treedfe06d5b38a34aa41cfe533b65b4927782910d7a
parent04c362ee1d4ed2b736310389a23ea94bdad5e9d7 (diff)
Fix Refcounting Bug Shown By __doc__ Handling
There was a bug in the signature function 'GetClassOfFunc' since last November (sha1 2533dab013455bf94da2d4766e54abaf4d735e1e). A type was returned without Py_INCREF. That happens because types are often looked up, only, but here a normal return needed a ref. Change-Id: I3e0956b341d2b0753da2e33dd9f557b6a693098d Fixes: PYSIDE-928 Fixes: PYSIDE-937 Fixes: PYSIDE-943 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index 61a09777..cd00a148 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -167,8 +167,11 @@ _get_class_of_descr(PyObject *ob)
static PyObject *
GetClassOfFunc(PyObject *ob)
{
- if (PyType_Check(ob))
+ if (PyType_Check(ob)) {
+ // PySide-928: The type case must do refcounting like the others as well.
+ Py_INCREF(ob);
return ob;
+ }
if (PyType_IsSubtype(Py_TYPE(ob), &PyCFunction_Type))
return _get_class_of_cf(ob);
if (Py_TYPE(ob) == PepStaticMethod_TypePtr)
@@ -535,6 +538,10 @@ error:
static int
_fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
{
+ /*
+ * This function pre-fills all fields of the new gsp. We then
+ * insert the changed values.
+ */
PyGetSetDef *gsp = type->tp_getset;
if (gsp != nullptr) {
for (; gsp->name != NULL; gsp++) {
@@ -542,7 +549,7 @@ _fixup_getset(PyTypeObject *type, const char *name, PyGetSetDef *new_gsp)
new_gsp->set = gsp->set;
new_gsp->doc = gsp->doc;
new_gsp->closure = gsp->closure;
- return 1;
+ return 1; // success
}
}
}