]> granicus.if.org Git - python/commitdiff
Issue #14125: backport refleak fix (d4adbf908983).
authorStefan Krah <skrah@bytereef.org>
Mon, 27 Feb 2012 16:34:17 +0000 (17:34 +0100)
committerStefan Krah <skrah@bytereef.org>
Mon, 27 Feb 2012 16:34:17 +0000 (17:34 +0100)
Modules/timemodule.c

index 3ab6e9b845601061dd2c8943730dca6eeda95b41..626db3e251f68d4afa7cb4ae616af1430c3732e5 100644 (file)
@@ -504,7 +504,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;
@@ -516,7 +516,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