summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/cfield.c5
-rw-r--r--Modules/socketmodule.c6
2 files changed, 9 insertions, 2 deletions
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index b6f41fe..ecb86be 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -1472,11 +1472,14 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
size += 1; /* terminating NUL */
size *= sizeof(wchar_t);
buffer = (wchar_t *)PyMem_Malloc(size);
- if (!buffer)
+ if (!buffer) {
+ Py_DECREF(value);
return PyErr_NoMemory();
+ }
memset(buffer, 0, size);
keep = PyCObject_FromVoidPtr(buffer, PyMem_Free);
if (!keep) {
+ Py_DECREF(value);
PyMem_Free(buffer);
return NULL;
}
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 7d91af2..b7b9a64 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3159,7 +3159,11 @@ socket_gethostbyaddr(PyObject *self, PyObject *args)
#ifdef HAVE_GETHOSTBYNAME_R_3_ARG
struct hostent_data data;
#else
- char buf[16384];
+ /* glibcs up to 2.10 assume that the buf argument to
+ gethostbyaddr_r is 8-byte aligned, which at least llvm-gcc
+ does not ensure. The attribute below instructs the compiler
+ to maintain this alignment. */
+ char buf[16384] Py_ALIGNED(8);
int buf_len = (sizeof buf) - 1;
int errnop;
#endif