summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Python/modsupport.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/modsupport.c b/Python/modsupport.c
index eb0818c..8fad54a 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -60,14 +60,18 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
v = PyCFunction_New(ml, passthrough);
if (v == NULL)
return NULL;
- if (PyDict_SetItemString(d, ml->ml_name, v) != 0)
+ if (PyDict_SetItemString(d, ml->ml_name, v) != 0) {
+ Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}
if (doc != NULL) {
v = PyString_FromString(doc);
- if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0)
+ if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
+ Py_DECREF(v);
return NULL;
+ }
Py_DECREF(v);
}
return m;