Commit dc2ff5baabf89d473d61ae4b468638f8ea98bb04

Anthony Green 2017-10-25T13:11:40

Merge pull request #323 from compnerd/x86-alloca-alignment x86: align alloca to 16-byte boundary

diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 3b4e25e..897498f 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -32,6 +32,7 @@
 #ifndef __x86_64__
 #include <ffi.h>
 #include <ffi_common.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include "internal.h"
 
@@ -674,7 +675,8 @@ ffi_raw_call(ffi_cif *cif, void (*fn)(void), void *rvalue, ffi_raw *avalue)
     }
 
   bytes = cif->bytes;
-  argp = stack = alloca(bytes + sizeof(*frame) + rsize);
+  argp = stack =
+      (void *)((uintptr_t)alloca(bytes + sizeof(*frame) + rsize + 15) & ~16);
   frame = (struct call_frame *)(stack + bytes);
   if (rsize)
     rvalue = frame + 1;