Skip to content

Commit 662f960

Browse files
author
neal.norwitz
committed
Fix a few more ref leaks. Backport candidate
git-svn-id: http://svn.python.org/projects/python/trunk@41531 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 2395ec0 commit 662f960

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

Python/codecs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ int PyCodec_Register(PyObject *search_function)
3636
goto onError;
3737
}
3838
if (!PyCallable_Check(search_function)) {
39-
PyErr_SetString(PyExc_TypeError,
40-
"argument must be callable");
39+
PyErr_SetString(PyExc_TypeError, "argument must be callable");
4140
goto onError;
4241
}
4342
return PyList_Append(interp->codec_search_path, search_function);
@@ -305,7 +304,7 @@ PyObject *PyCodec_Encode(PyObject *object,
305304
const char *errors)
306305
{
307306
PyObject *encoder = NULL;
308-
PyObject *args = NULL, *result;
307+
PyObject *args = NULL, *result = NULL;
309308
PyObject *v;
310309

311310
encoder = PyCodec_Encoder(encoding);
@@ -336,6 +335,7 @@ PyObject *PyCodec_Encode(PyObject *object,
336335
return v;
337336

338337
onError:
338+
Py_XDECREF(result);
339339
Py_XDECREF(args);
340340
Py_XDECREF(encoder);
341341
return NULL;

Python/compile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,6 +1801,7 @@ compiler_lookup_arg(PyObject *dict, PyObject *name)
18011801
if (k == NULL)
18021802
return -1;
18031803
v = PyDict_GetItem(dict, k);
1804+
Py_DECREF(k);
18041805
if (v == NULL)
18051806
return -1;
18061807
return PyInt_AS_LONG(v);
@@ -2464,6 +2465,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
24642465
}
24652466

24662467
ADDOP_O(c, LOAD_CONST, names, consts);
2468+
Py_DECREF(names);
24672469
ADDOP_NAME(c, IMPORT_NAME, s->v.ImportFrom.module, names);
24682470
for (i = 0; i < n; i++) {
24692471
alias_ty alias = asdl_seq_GET(s->v.ImportFrom.names, i);

Python/symtable.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,8 +1278,10 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
12781278
else {
12791279
if (st->st_cur->ste_type != ModuleBlock) {
12801280
if (!symtable_warn(st,
1281-
"import * only allowed at module level"))
1281+
"import * only allowed at module level")) {
1282+
Py_DECREF(store_name);
12821283
return 0;
1284+
}
12831285
}
12841286
st->st_cur->ste_unoptimized |= OPT_IMPORT_STAR;
12851287
Py_DECREF(store_name);

0 commit comments

Comments
 (0)