]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-124606: Fix reference leak in error path in `datetime_fromisoformat` in `_datetime...
authorKirill Podoprigora <kirill.bast9@mail.ru>
Thu, 26 Sep 2024 15:30:21 +0000 (18:30 +0300)
committerGitHub <noreply@github.com>
Thu, 26 Sep 2024 15:30:21 +0000 (15:30 +0000)
Previously `tzdata` and `dtstr_clean` were not decrefed in the `invalid_iso_midnight` error path of the `datetime_isoformat` function.

Modules/_datetimemodule.c

index 0d91bef2ff9bdac7ac803cc05e3dac938b652903..90527d2a3e0350718673fb5503488dd7bfe15010 100644 (file)
@@ -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: