From: Victor Stinner Date: Fri, 4 Nov 2022 13:24:10 +0000 (+0100) Subject: gh-90716: Fix pylong_int_from_string() refleak (#99094) X-Git-Tag: v3.12.0a2~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=387f72588d538bc56669f0f28cc41df854fc5b43;p=thirdparty%2FPython%2Fcpython.git gh-90716: Fix pylong_int_from_string() refleak (#99094) Fix validated by: $ ./python -m test -R 3:3 test_int Tests result: SUCCESS --- diff --git a/Objects/longobject.c b/Objects/longobject.c index a87293899001..652fdb7974b1 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2376,6 +2376,7 @@ pylong_int_from_string(const char *start, const char *end, PyLongObject **res) goto error; } if (!PyLong_Check(result)) { + Py_DECREF(result); PyErr_SetString(PyExc_TypeError, "_pylong.int_from_string did not return an int"); goto error;