From 00ff10cae426a529ea9aa473e0ba9ab905cf7c81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 11 Nov 2001 14:24:05 +0000 Subject: Patch in bug report #477700: Fix memory leaks in gdbm & curses. --- Modules/_cursesmodule.c | 1 + Modules/gdbmmodule.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index bd544ba..e6f5ef1 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -2544,6 +2544,7 @@ init_curses(void) /* Add a CObject for the C API */ c_api_object = PyCObject_FromVoidPtr((void *)PyCurses_API, NULL); PyDict_SetItemString(d, "_C_API", c_api_object); + Py_DECREF(c_api_object); /* For exception curses.error */ PyCursesError = PyErr_NewException("_curses.error", NULL, NULL); diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c index 5f83a28..0190a9b 100644 --- a/Modules/gdbmmodule.c +++ b/Modules/gdbmmodule.c @@ -505,7 +505,7 @@ static PyMethodDef dbmmodule_methods[] = { DL_EXPORT(void) initgdbm(void) { - PyObject *m, *d; + PyObject *m, *d, *s; Dbmtype.ob_type = &PyType_Type; m = Py_InitModule4("gdbm", dbmmodule_methods, @@ -515,7 +515,8 @@ initgdbm(void) { DbmError = PyErr_NewException("gdbm.error", NULL, NULL); if (DbmError != NULL) { PyDict_SetItemString(d, "error", DbmError); - PyDict_SetItemString(d, "open_flags", - PyString_FromString(dbmmodule_open_flags)); + s = PyString_FromString(dbmmodule_open_flags); + PyDict_SetItemString(d, "open_flags", s); + Py_DECREF(s); } } -- cgit v0.12