[Python-checkins] cpython: Issue #14125: Fix refleak in timemodule.c on Windows. Thanks sbt for pointing

stefan.krah python-checkins at python.org
Mon Feb 27 16:33:30 CET 2012


http://hg.python.org/cpython/rev/d4adbf908983
changeset:   75315:d4adbf908983
user:        Stefan Krah <skrah at bytereef.org>
date:        Mon Feb 27 16:30:26 2012 +0100
summary:
  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.

files:
  Modules/timemodule.c |  5 +++--
  1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -540,7 +540,7 @@
     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 @@
             !strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
         {
             PyErr_SetString(PyExc_ValueError, "Invalid format string");
-            return 0;
+            Py_DECREF(format);
+            return NULL;
         }
     }
 #endif

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list