diff Python/compile.c @ 28402:5f5364ac4adb legacy-trunk

symtable_cellvar_offsets(): This leaked references to little integers in normal cases, and also in error cases. Bugfix candidate.
author Tim Peters <tim.peters@gmail.com>
date Mon, 24 Mar 2003 17:22:24 +0000
parents e9d7102f8278
children 733729261c41
line wrap: on
line diff
--- a/Python/compile.c	Mon Mar 24 12:13:54 2003 +0000
+++ b/Python/compile.c	Mon Mar 24 17:22:24 2003 +0000
@@ -4496,7 +4496,8 @@
 symtable_cellvar_offsets(PyObject **cellvars, int argcount, 
 			 PyObject *varnames, int flags) 
 {
-	PyObject *v, *w, *d, *list = NULL;
+	PyObject *v = NULL;
+	PyObject *w, *d, *list = NULL;
 	int i, pos;
 
 	if (flags & CO_VARARGS)
@@ -4530,6 +4531,7 @@
 			goto fail;
 		if (PyDict_DelItem(*cellvars, PyList_GET_ITEM(list, i)) < 0)
 			goto fail;
+		Py_DECREF(v);
 	}
 	pos = 0;
 	i = PyList_GET_SIZE(list);
@@ -4538,6 +4540,7 @@
 		w = PyInt_FromLong(i++);  /* don't care about the old key */
 		if (PyDict_SetItem(d, v, w) < 0) {
 			Py_DECREF(w);
+			v = NULL;
 			goto fail;
 		}
 		Py_DECREF(w);
@@ -4547,6 +4550,7 @@
 	return 1;
  fail:
 	Py_DECREF(d);
+	Py_XDECREF(v);
 	return -1;
 }