summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-12-15 05:05:16 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-12-15 05:05:16 (GMT)
commit5cb8a31dc46db672ac442fcd78b5acc5dad74e91 (patch)
treee811c5c2cc43a7eb3eb0d27585395f1760d7f061 /Python/import.c
parente0a908290cc7226d441cbf595a2643ad4508f61c (diff)
downloadcpython-5cb8a31dc46db672ac442fcd78b5acc5dad74e91.zip
cpython-5cb8a31dc46db672ac442fcd78b5acc5dad74e91.tar.gz
cpython-5cb8a31dc46db672ac442fcd78b5acc5dad74e91.tar.bz2
cleanup and fix refleaks
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Python/import.c b/Python/import.c
index 8e7482a..5026789 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -470,8 +470,9 @@ int
_PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
PyObject *filename)
{
- PyObject *modules, *dict, *filename_name;
+ PyObject *modules, *dict, *key;
struct PyModuleDef *def;
+ int res;
if (extensions == NULL) {
extensions = PyDict_New();
if (extensions == NULL)
@@ -508,10 +509,12 @@ _PyImport_FixupExtensionObject(PyObject *mod, PyObject *name,
if (def->m_base.m_copy == NULL)
return -1;
}
- filename_name = PyTuple_Pack(2,filename, name);
- if (filename_name == NULL)
+ key = PyTuple_Pack(2, filename, name);
+ if (key == NULL)
return -1;
- if (PyDict_SetItem(extensions, filename_name, (PyObject*)def) < 0)
+ res = PyDict_SetItem(extensions, key, (PyObject *)def);
+ Py_DECREF(key);
+ if (res < 0)
return -1;
return 0;
}
@@ -532,14 +535,15 @@ _PyImport_FixupBuiltin(PyObject *mod, char *name)
PyObject *
_PyImport_FindExtensionObject(PyObject *name, PyObject *filename)
{
- PyObject *mod, *mdict, *filename_name;
+ PyObject *mod, *mdict, *key;
PyModuleDef* def;
if (extensions == NULL)
return NULL;
- filename_name = PyTuple_Pack(2,filename, name);
- if (filename_name == NULL)
+ key = PyTuple_Pack(2, filename, name);
+ if (key == NULL)
return NULL;
- def = (PyModuleDef*)PyDict_GetItem(extensions, filename_name);
+ def = (PyModuleDef *)PyDict_GetItem(extensions, key);
+ Py_DECREF(key);
if (def == NULL)
return NULL;
if (def->m_size == -1) {