Commit 4aea7d38 authored by Stefan Krah's avatar Stefan Krah

Issue #14125: Fix refleak in timemodule.c on Windows. Thanks sbt for pointing

out the location of the problem. MS_WINDOWS currently implies !HAVE_WCSFTIME,
so the addition of !defined(HAVE_WCSFTIME) is for readability.
parent a03422f5
...@@ -540,7 +540,7 @@ time_strftime(PyObject *self, PyObject *args) ...@@ -540,7 +540,7 @@ time_strftime(PyObject *self, PyObject *args)
fmt = PyBytes_AS_STRING(format); fmt = PyBytes_AS_STRING(format);
#endif #endif
#if defined(MS_WINDOWS) #if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME)
/* check that the format string contains only valid directives */ /* check that the format string contains only valid directives */
for(outbuf = strchr(fmt, '%'); for(outbuf = strchr(fmt, '%');
outbuf != NULL; outbuf != NULL;
...@@ -552,7 +552,8 @@ time_strftime(PyObject *self, PyObject *args) ...@@ -552,7 +552,8 @@ time_strftime(PyObject *self, PyObject *args)
!strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1])) !strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
{ {
PyErr_SetString(PyExc_ValueError, "Invalid format string"); PyErr_SetString(PyExc_ValueError, "Invalid format string");
return 0; Py_DECREF(format);
return NULL;
} }
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment