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

Skip to content

Commit 4aea7d3

Browse files
author
Stefan Krah
committed
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.
1 parent a03422f commit 4aea7d3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Modules/timemodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ time_strftime(PyObject *self, PyObject *args)
540540
fmt = PyBytes_AS_STRING(format);
541541
#endif
542542

543-
#if defined(MS_WINDOWS)
543+
#if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME)
544544
/* check that the format string contains only valid directives */
545545
for(outbuf = strchr(fmt, '%');
546546
outbuf != NULL;
@@ -552,7 +552,8 @@ time_strftime(PyObject *self, PyObject *args)
552552
!strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
553553
{
554554
PyErr_SetString(PyExc_ValueError, "Invalid format string");
555-
return 0;
555+
Py_DECREF(format);
556+
return NULL;
556557
}
557558
}
558559
#endif

0 commit comments

Comments
 (0)