summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorThomas Heller <theller@ctypes.org>2008-02-06 20:29:17 (GMT)
committerThomas Heller <theller@ctypes.org>2008-02-06 20:29:17 (GMT)
commit55b8c3e26fe608a1caf65cb35e41cdcbd8353426 (patch)
tree96296cfacd93d2a552cf19bfa9a0b89608bd76c8 /Modules
parent5af2f7454daec9b8526ce5437783137f17a0bce3 (diff)
downloadcpython-55b8c3e26fe608a1caf65cb35e41cdcbd8353426.zip
cpython-55b8c3e26fe608a1caf65cb35e41cdcbd8353426.tar.gz
cpython-55b8c3e26fe608a1caf65cb35e41cdcbd8353426.tar.bz2
Fixed refcounts and error handling.
Should not be merged to py3k branch.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 5d3cba5..52959e4 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4956,16 +4956,19 @@ create_comerror(void)
PyObject *s;
int status;
+ if (dict == NULL)
+ return -1;
+
while (methods->ml_name) {
/* get a wrapper for the built-in function */
PyObject *func = PyCFunction_New(methods, NULL);
PyObject *meth;
if (func == NULL)
- return -1;
+ goto error;
meth = PyMethod_New(func, NULL, ComError);
Py_DECREF(func);
if (meth == NULL)
- return -1;
+ goto error;
PyDict_SetItemString(dict, methods->ml_name, meth);
Py_DECREF(meth);
++methods;
@@ -4973,21 +4976,22 @@ create_comerror(void)
s = PyString_FromString(comerror_doc);
if (s == NULL)
- return -1;
+ goto error;
status = PyDict_SetItemString(dict, "__doc__", s);
Py_DECREF(s);
- if (status == -1) {
- Py_DECREF(dict);
- return -1;
- }
+ if (status == -1)
+ goto error;
ComError = PyErr_NewException("_ctypes.COMError",
NULL,
dict);
if (ComError == NULL)
- return -1;
+ goto error;
return 0;
+ error:
+ Py_DECREF(dict);
+ return -1;
}
#endif