summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c20
-rw-r--r--Modules/_ctypes/callbacks.c2
-rw-r--r--Modules/_ctypes/ctypes.h2
-rw-r--r--Modules/_ctypes/stgdict.c2
4 files changed, 15 insertions, 11 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 35f087d..0350be3 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -4466,11 +4466,6 @@ create_comerror(void)
PyObject *s;
int status;
- ComError = PyErr_NewException("_ctypes.COMError",
- NULL,
- dict);
- if (ComError == NULL)
- return -1;
while (methods->ml_name) {
/* get a wrapper for the built-in function */
PyObject *func = PyCFunction_New(methods, NULL);
@@ -4485,13 +4480,24 @@ create_comerror(void)
Py_DECREF(meth);
++methods;
}
- Py_INCREF(ComError);
+
s = PyString_FromString(comerror_doc);
if (s == NULL)
return -1;
status = PyDict_SetItemString(dict, "__doc__", s);
Py_DECREF(s);
- return status;
+ if (status == -1) {
+ Py_DECREF(dict);
+ return -1;
+ }
+
+ ComError = PyErr_NewException("_ctypes.COMError",
+ NULL,
+ dict);
+ if (ComError == NULL)
+ return -1;
+
+ return 0;
}
#endif
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 82f6cc1..5915455 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -264,7 +264,7 @@ ffi_info *AllocFunctionCallback(PyObject *callable,
ffi_abi cc;
nArgs = PySequence_Size(converters);
- p = (ffi_info *)PyMem_Malloc(sizeof(ffi_info) + sizeof(ffi_type) * (nArgs + 1));
+ p = (ffi_info *)PyMem_Malloc(sizeof(ffi_info) + sizeof(ffi_type) * (nArgs));
if (p == NULL) {
PyErr_NoMemory();
return NULL;
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index 5df9943..52f6065 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -58,7 +58,7 @@ typedef struct {
PyObject *callable;
SETFUNC setfunc;
ffi_type *restype;
- ffi_type *atypes[0];
+ ffi_type *atypes[1];
} ffi_info;
typedef struct {
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index fd6f5e2..b4a6e87 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -457,13 +457,11 @@ StructUnionType_update_stgdict(PyObject *type, PyObject *fields, int isStruct)
if (!prop) {
Py_DECREF(pair);
- Py_DECREF((PyObject *)stgdict);
return -1;
}
if (-1 == PyDict_SetItem(realdict, name, prop)) {
Py_DECREF(prop);
Py_DECREF(pair);
- Py_DECREF((PyObject *)stgdict);
return -1;
}
Py_DECREF(pair);