summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-07-27 14:58:47 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-07-27 14:58:47 (GMT)
commite33797b686d764014aeaf80d7b4cb24863d238d9 (patch)
tree128f18a0449e8b96979e9f84999804c8dd75c19c
parent25539b089f24f78446d276360602a7beff11a4d7 (diff)
downloadcpython-e33797b686d764014aeaf80d7b4cb24863d238d9.zip
cpython-e33797b686d764014aeaf80d7b4cb24863d238d9.tar.gz
cpython-e33797b686d764014aeaf80d7b4cb24863d238d9.tar.bz2
ctypes: fix CThunkObject_new()
* Initialize restype and flags fields to fix a crash when Python runs on a read-only file system * Use Py_ssize_t type rather than int for the "i" iterator variable * Reorder assignements to be able to more easily check if all fields are initialized Issue #11048. Initial patch written by Marcin Bachry.
-rw-r--r--Modules/_ctypes/callbacks.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 7cd6164..91413d7 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -305,7 +305,7 @@ static void closure_fcn(ffi_cif *cif,
static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
{
CThunkObject *p;
- int i;
+ Py_ssize_t i;
p = PyObject_GC_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
if (p == NULL) {
@@ -313,11 +313,13 @@ static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
return NULL;
}
- p->pcl_exec = NULL;
p->pcl_write = NULL;
+ p->pcl_exec = NULL;
memset(&p->cif, 0, sizeof(p->cif));
+ p->flags = 0;
p->converters = NULL;
p->callable = NULL;
+ p->restype = NULL;
p->setfunc = NULL;
p->ffi_restype = NULL;