From 024800a1331d38794c24cf191cd74b70af1078a1 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Thu, 24 Jan 2019 08:24:32 +0100 Subject: [PATCH] Fix Win32 stdcall closure The stack pointer has been incorrectly restored after a closure call. The issue came up at ruby-ffi: https://github.com/ffi/ffi/issues/649 Patch by Alexander Mitin. Fixes #215 --- src/x86/ffi.c | 2 +- src/x86/ffiw64.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/x86/ffi.c b/src/x86/ffi.c index cad32e8a0..73f69e095 100644 --- a/src/x86/ffi.c +++ b/src/x86/ffi.c @@ -177,7 +177,7 @@ ffi_prep_cif_machdep(ffi_cif *cif) bytes = FFI_ALIGN (bytes, t->alignment); bytes += FFI_ALIGN (t->size, FFI_SIZEOF_ARG); } - cif->bytes = FFI_ALIGN (bytes, 16); + cif->bytes = FFI_ALIGN (bytes, FFI_SIZEOF_ARG); return FFI_OK; } diff --git a/src/x86/ffiw64.c b/src/x86/ffiw64.c index f78752522..da44a0907 100644 --- a/src/x86/ffiw64.c +++ b/src/x86/ffiw64.c @@ -101,7 +101,7 @@ EFI64(ffi_prep_cif_machdep)(ffi_cif *cif) n += (flags == FFI_TYPE_STRUCT); if (n < 4) n = 4; - cif->bytes = n * 8; + cif->bytes = n * FFI_SIZEOF_ARG; return FFI_OK; }