From: Raymond Hettinger Date: Thu, 10 Apr 2003 16:03:22 +0000 (+0000) Subject: SF patch #718867: Fix reference leak for time.strptime X-Git-Tag: v2.3c1~1230 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=502168a86e4c0bce83f491879fcf02836bc0fbb2;p=python SF patch #718867: Fix reference leak for time.strptime (contributed by Brett Cannon) --- diff --git a/Modules/timemodule.c b/Modules/timemodule.c index fc81ca4069..2e28d95f65 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -454,10 +454,13 @@ static PyObject * time_strptime(PyObject *self, PyObject *args) { PyObject *strptime_module = PyImport_ImportModule("_strptime"); + PyObject *strptime_result; if (!strptime_module) return NULL; - return PyObject_CallMethod(strptime_module, "strptime", "O", args); + strptime_result = PyObject_CallMethod(strptime_module, "strptime", "O", args); + Py_DECREF(strptime_module); + return strptime_result; } #endif /* !HAVE_STRPTIME */