diff options
author | Petr Viktorin <encukou@gmail.com> | 2024-04-01 15:01:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-01 15:01:22 (GMT) |
commit | 179869af922252a0c1cef65fd2923856895e7d1b (patch) | |
tree | 3baaf2904add9219a58a3f9d56a293709371f1f5 | |
parent | dd44ab994b7262f0704d64996e0a1bc37b233407 (diff) | |
download | cpython-179869af922252a0c1cef65fd2923856895e7d1b.zip cpython-179869af922252a0c1cef65fd2923856895e7d1b.tar.gz cpython-179869af922252a0c1cef65fd2923856895e7d1b.tar.bz2 |
gh-94808: Fix refcounting in PyObject_Print tests (GH-117421)
-rw-r--r-- | Modules/_testcapi/object.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testcapi/object.c b/Modules/_testcapi/object.c index ce5b574..8dd34cf 100644 --- a/Modules/_testcapi/object.c +++ b/Modules/_testcapi/object.c @@ -76,6 +76,8 @@ pyobject_print_noref_object(PyObject *self, PyObject *args) if (PyObject_Print(test_string, fp, 0) < 0){ fclose(fp); + Py_SET_REFCNT(test_string, 1); + Py_DECREF(test_string); return NULL; } @@ -105,10 +107,12 @@ pyobject_print_os_error(PyObject *self, PyObject *args) if (PyObject_Print(test_string, fp, 0) < 0) { fclose(fp); + Py_DECREF(test_string); return NULL; } fclose(fp); + Py_DECREF(test_string); Py_RETURN_NONE; } |