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

Skip to content

Commit 2201ecb

Browse files
author
Stefan Krah
committed
Issue #14125: backport refleak fix (d4adbf908983).
1 parent 982f534 commit 2201ecb

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
@@ -504,7 +504,7 @@ time_strftime(PyObject *self, PyObject *args)
504504
fmt = PyBytes_AS_STRING(format);
505505
#endif
506506

507-
#if defined(MS_WINDOWS)
507+
#if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME)
508508
/* check that the format string contains only valid directives */
509509
for(outbuf = strchr(fmt, '%');
510510
outbuf != NULL;
@@ -516,7 +516,8 @@ time_strftime(PyObject *self, PyObject *args)
516516
!strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
517517
{
518518
PyErr_SetString(PyExc_ValueError, "Invalid format string");
519-
return 0;
519+
Py_DECREF(format);
520+
return NULL;
520521
}
521522
}
522523
#endif

0 commit comments

Comments
 (0)