summaryrefslogtreecommitdiffstats
path: root/Modules/timemodule.c
diff options
context:
space:
mode:
authorStefan Krah <skrah@bytereef.org>2012-02-27 15:30:26 (GMT)
committerStefan Krah <skrah@bytereef.org>2012-02-27 15:30:26 (GMT)
commit4aea7d3811970e1f88f0804baaf55fa94987772c (patch)
treee295d7208eb99c5a9732a7ef9ccfc849d4996850 /Modules/timemodule.c
parenta03422f5d3a0780bfde5e4aa7ee05e1eb9a090fd (diff)
downloadcpython-4aea7d3811970e1f88f0804baaf55fa94987772c.zip
cpython-4aea7d3811970e1f88f0804baaf55fa94987772c.tar.gz
cpython-4aea7d3811970e1f88f0804baaf55fa94987772c.tar.bz2
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.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r--Modules/timemodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 34c7019..59fe3ee 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -540,7 +540,7 @@ time_strftime(PyObject *self, PyObject *args)
fmt = PyBytes_AS_STRING(format);
#endif
-#if defined(MS_WINDOWS)
+#if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME)
/* check that the format string contains only valid directives */
for(outbuf = strchr(fmt, '%');
outbuf != NULL;
@@ -552,7 +552,8 @@ time_strftime(PyObject *self, PyObject *args)
!strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
{
PyErr_SetString(PyExc_ValueError, "Invalid format string");
- return 0;
+ Py_DECREF(format);
+ return NULL;
}
}
#endif