aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2023-02-14 14:46:22 +0100
committerChristian Tismer <tismer@stackless.com>2023-03-06 16:59:46 +0100
commitada31927752ccd77146d72b81846532b3950366e (patch)
treea241b619556f6d96d36e3d5a5e1e564cb85198ad
parentc77180804c16f120217830d66039e0889a7684ac (diff)
debug: fix refcount of disassembleFrame
It is always a bad idea to ignore an unused value in CPython function calls, because that generates a refcount leak. This was forgotten to fix. Recognized when seeking the last refcount bug in pysideproperty.cpp . Change-Id: I737bed654660ad78479989d5004b2c44637274fc Task-number: PYSIDE-1402 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 05958ae2ab03533c847f0ff17839286c562e3d5c) Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io>
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
index 2931a8abd..6cb77d17e 100644
--- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
@@ -57,12 +57,12 @@ void disassembleFrame(const char *marker)
auto *frame = reinterpret_cast<PyObject *>(PyEval_GetFrame());
AutoDecRef f_lasti(PyObject_GetAttr(frame, _f_lasti));
AutoDecRef f_code(PyObject_GetAttr(frame, _f_code));
+ AutoDecRef ignore{};
fprintf(stdout, "\n%s BEGIN\n", marker);
- PyObject_CallFunctionObjArgs(disco, f_code.object(), f_lasti.object(), nullptr);
+ ignore.reset(PyObject_CallFunctionObjArgs(disco, f_code.object(), f_lasti.object(), nullptr));
fprintf(stdout, "%s END\n\n", marker);
- static PyObject *sysmodule = PyImport_ImportModule("sys");
- static PyObject *stdout_file = PyObject_GetAttrString(sysmodule, "stdout");
- PyObject_CallMethod(stdout_file, "flush", nullptr);
+ static PyObject *stdout_file = PySys_GetObject("stdout");
+ ignore.reset(PyObject_CallMethod(stdout_file, "flush", nullptr));
PyErr_Restore(error_type, error_value, error_traceback);
}