[Python-checkins] cpython (2.7): ctypes: fix CThunkObject_new()
victor.stinner
python-checkins at python.org
Wed Jul 27 11:00:40 EDT 2016
https://hg.python.org/cpython/rev/7d692840c152
changeset: 102462:7d692840c152
branch: 2.7
parent: 102449:55b6e51b878b
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Jul 27 16:58:47 2016 +0200
summary:
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.
files:
Modules/_ctypes/callbacks.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -385,7 +385,7 @@
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) {
@@ -393,11 +393,13 @@
return NULL;
}
+ p->pcl_write = NULL;
p->pcl_exec = NULL;
- p->pcl_write = 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;
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list