Fix a few more ref leaks. Backport candidate
diff --git a/Python/codecs.c b/Python/codecs.c
index 4b8d983..5c521fb 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -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;
diff --git a/Python/compile.c b/Python/compile.c
index 5905c45..418194e 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -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);
diff --git a/Python/symtable.c b/Python/symtable.c
index 9eff334..016251c 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -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);