summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKirill Podoprigora <kirill.bast9@mail.ru>2024-09-26 15:30:21 (GMT)
committerGitHub <noreply@github.com>2024-09-26 15:30:21 (GMT)
commit9c98fdab7d1167211c9d162c418e2b443a02867a (patch)
tree819e43fcfcbaf7a2a49e68fbb948e22327b9ff5b
parent257a20a81764fcc17bcde9c0cec57fbc53a4adc7 (diff)
downloadcpython-9c98fdab7d1167211c9d162c418e2b443a02867a.zip
cpython-9c98fdab7d1167211c9d162c418e2b443a02867a.tar.gz
cpython-9c98fdab7d1167211c9d162c418e2b443a02867a.tar.bz2
gh-124606: Fix reference leak in error path in `datetime_fromisoformat` in `_datetimemodule.c` (#124607)
Previously `tzdata` and `dtstr_clean` were not decrefed in the `invalid_iso_midnight` error path of the `datetime_isoformat` function.
-rw-r--r--Modules/_datetimemodule.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 0d91bef..90527d2 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -5959,6 +5959,8 @@ datetime_fromisoformat(PyObject *cls, PyObject *dtstr)
invalid_iso_midnight:
PyErr_SetString(PyExc_ValueError, "minute, second, and microsecond must be 0 when hour is 24");
+ Py_DECREF(tzinfo);
+ Py_DECREF(dtstr_clean);
return NULL;
invalid_string_error: