[Python-checkins] commit of r41531 - python/trunk/Python

neal.norwitz@python.org neal.norwitz at python.org
Thu Nov 24 23:09:24 CET 2005


Author: neal.norwitz
Date: Thu Nov 24 23:09:18 2005
New Revision: 41531

Modified:
   python/trunk/Python/codecs.c
   python/trunk/Python/compile.c
   python/trunk/Python/symtable.c
Log:
Fix a few more ref leaks.  Backport candidate

Modified: python/trunk/Python/codecs.c
==============================================================================
--- python/trunk/Python/codecs.c	(original)
+++ python/trunk/Python/codecs.c	Thu Nov 24 23:09:18 2005
@@ -36,8 +36,7 @@
 	goto onError;
     }
     if (!PyCallable_Check(search_function)) {
-	PyErr_SetString(PyExc_TypeError,
-			"argument must be callable");
+	PyErr_SetString(PyExc_TypeError, "argument must be callable");
 	goto onError;
     }
     return PyList_Append(interp->codec_search_path, search_function);
@@ -305,7 +304,7 @@
 			 const char *errors)
 {
     PyObject *encoder = NULL;
-    PyObject *args = NULL, *result;
+    PyObject *args = NULL, *result = NULL;
     PyObject *v;
 
     encoder = PyCodec_Encoder(encoding);
@@ -336,6 +335,7 @@
     return v;
 	
  onError:
+    Py_XDECREF(result);
     Py_XDECREF(args);
     Py_XDECREF(encoder);
     return NULL;

Modified: python/trunk/Python/compile.c
==============================================================================
--- python/trunk/Python/compile.c	(original)
+++ python/trunk/Python/compile.c	Thu Nov 24 23:09:18 2005
@@ -1801,6 +1801,7 @@
     if (k == NULL)
         return -1;
     v = PyDict_GetItem(dict, k);
+    Py_DECREF(k);
     if (v == NULL)
         return -1;
     return PyInt_AS_LONG(v);
@@ -2464,6 +2465,7 @@
 	}
 
 	ADDOP_O(c, LOAD_CONST, names, consts);
+	Py_DECREF(names);
 	ADDOP_NAME(c, IMPORT_NAME, s->v.ImportFrom.module, names);
 	for (i = 0; i < n; i++) {
 		alias_ty alias = asdl_seq_GET(s->v.ImportFrom.names, i);

Modified: python/trunk/Python/symtable.c
==============================================================================
--- python/trunk/Python/symtable.c	(original)
+++ python/trunk/Python/symtable.c	Thu Nov 24 23:09:18 2005
@@ -1278,8 +1278,10 @@
 	else {
             if (st->st_cur->ste_type != ModuleBlock) {
                 if (!symtable_warn(st,
-                                   "import * only allowed at module level"))
+                                   "import * only allowed at module level")) {
+                    Py_DECREF(store_name);
                     return 0;
+		}
             }
 	    st->st_cur->ste_unoptimized |= OPT_IMPORT_STAR;
 	    Py_DECREF(store_name);


More information about the Python-checkins mailing list