]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Christopher Fandrich <cfandrich@8cs.com>:
authorFred Drake <fdrake@acm.org>
Tue, 20 Jun 2000 04:54:19 +0000 (04:54 +0000)
committerFred Drake <fdrake@acm.org>
Tue, 20 Jun 2000 04:54:19 +0000 (04:54 +0000)
Fix memory leak in initializing __debug__.

Python/bltinmodule.c

index f4a780267148714bb5e96973341e18419b8e44b1..6d2a0fcde0e1ea4bc8b97a3a3b9a638e2de6c210 100644 (file)
@@ -2364,7 +2364,7 @@ Noteworthy: None is the `nil' object; Ellipsis represents `...' in slices.";
 PyObject *
 _PyBuiltin_Init()
 {
-       PyObject *mod, *dict;
+       PyObject *mod, *dict, *debug;
        mod = Py_InitModule4("__builtin__", builtin_methods,
                             builtin_doc, (PyObject *)NULL,
                             PYTHON_API_VERSION);
@@ -2375,9 +2375,12 @@ _PyBuiltin_Init()
                return NULL;
        if (PyDict_SetItemString(dict, "Ellipsis", Py_Ellipsis) < 0)
                return NULL;
-       if (PyDict_SetItemString(dict, "__debug__",
-                         PyInt_FromLong(Py_OptimizeFlag == 0)) < 0)
+       debug = PyInt_FromLong(Py_OptimizeFlag == 0);
+       if (PyDict_SetItemString(dict, "__debug__", debug) < 0) {
+               Py_XDECREF(debug);
                return NULL;
+       }
+       Py_XDECREF(debug);
 
        return mod;
 }