Skip to content

Commit

Permalink
Fix Win32 stdcall closure
Browse files Browse the repository at this point in the history
The stack pointer has been incorrectly restored after a closure call.

The issue came up at ruby-ffi: ffi/ffi#649

Patch by Alexander Mitin.

Fixes libffi#215
  • Loading branch information
larskanis committed Jan 24, 2019
1 parent 8fa8837 commit 024800a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/x86/ffi.c
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/x86/ffiw64.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 024800a

Please sign in to comment.