]> granicus.if.org Git - python/commitdiff
Fix a few more ref leaks. Backport candidate
authorNeal Norwitz <nnorwitz@gmail.com>
Thu, 24 Nov 2005 22:09:18 +0000 (22:09 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Thu, 24 Nov 2005 22:09:18 +0000 (22:09 +0000)
Python/codecs.c
Python/compile.c
Python/symtable.c

index 4b8d9839350ff4bef798d45f58b29cc640682119..5c521fb0b4ee7522c12a1c16998fba16e1a262c9 100644 (file)
@@ -36,8 +36,7 @@ int PyCodec_Register(PyObject *search_function)
        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 @@ PyObject *PyCodec_Encode(PyObject *object,
                         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 @@ PyObject *PyCodec_Encode(PyObject *object,
     return v;
        
  onError:
+    Py_XDECREF(result);
     Py_XDECREF(args);
     Py_XDECREF(encoder);
     return NULL;
index 5905c456c6ed5acc4a64b059995bfe1091de4af0..418194e1eef7ff016d4135ff9b15342302fed359 100644 (file)
@@ -1801,6 +1801,7 @@ compiler_lookup_arg(PyObject *dict, PyObject *name)
     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 @@ compiler_from_import(struct compiler *c, stmt_ty s)
        }
 
        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);
index 9eff3344b965e61c77c4f8c2d59b3a1d73211267..016251c2ab8342b7957a80b7feba669c95c4ea0b 100644 (file)
@@ -1278,8 +1278,10 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
        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);