Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Prev Previous commit
Next Next commit
Fix refleaks
  • Loading branch information
marat committed Sep 24, 2025
commit 40d0e1c149dbff7ff31a2e78be4b7c4bf5317ff0
19 changes: 17 additions & 2 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2055,10 +2055,25 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
else if (ch == '-' && i < flen) {
Py_UCS4 next_ch = PyUnicode_READ_CHAR(format, i);
i++;
replacement = make_dash_replacement(object, next_ch, timetuple);
if (replacement == NULL) {

PyObject *tmp = make_dash_replacement(object, next_ch, timetuple);
if (tmp == NULL) {
Py_DECREF(tmp);
Comment thread
mhsmith marked this conversation as resolved.
Outdated
goto Error;
}

if (PyUnicodeWriter_WriteSubstring(writer, format, start, end) < 0) {
Py_DECREF(tmp);
goto Error;
}
start = i;
if (PyUnicodeWriter_WriteStr(writer, tmp) < 0) {
Py_DECREF(tmp);
goto Error;
}

Py_DECREF(tmp);
continue;
}
#endif
else {
Expand Down
Loading