diff options
author | Andy Lester <andy@petdance.com> | 2020-03-25 04:26:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 04:26:44 (GMT) |
commit | 7668a8bc93c2bd573716d1bea0f52ea520502b28 (patch) | |
tree | 0c6dce63a06466c3f9136df09f5cd928d20e5c55 /Modules/_ctypes | |
parent | 7dd549eb08939e1927fba818116f5202e76f8d73 (diff) | |
download | cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.zip cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.tar.gz cpython-7668a8bc93c2bd573716d1bea0f52ea520502b28.tar.bz2 |
Use calloc-based functions, not malloc. (GH-19152)
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/callproc.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 5f29f95..d1c552a 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -156,10 +156,9 @@ _ctypes_get_errobj(int **pspace) Py_INCREF(errobj); } else if (!PyErr_Occurred()) { - void *space = PyMem_Malloc(sizeof(int) * 2); + void *space = PyMem_Calloc(2, sizeof(int)); if (space == NULL) return NULL; - memset(space, 0, sizeof(int) * 2); errobj = PyCapsule_New(space, CTYPES_CAPSULE_NAME_PYMEM, pymem_destructor); if (errobj == NULL) { PyMem_Free(space); @@ -1712,10 +1711,9 @@ resize(PyObject *self, PyObject *args) if (!_CDataObject_HasExternalBuffer(obj)) { /* We are currently using the objects default buffer, but it isn't large enough any more. */ - void *ptr = PyMem_Malloc(size); + void *ptr = PyMem_Calloc(1, size); if (ptr == NULL) return PyErr_NoMemory(); - memset(ptr, 0, size); memmove(ptr, obj->b_ptr, obj->b_size); obj->b_ptr = ptr; obj->b_size = size; |