From 901b2b61435ca939f03c55a696f4fdf2ad8ff721 Mon Sep 17 00:00:00 2001 From: Roza Date: Wed, 26 Feb 2020 18:47:46 -0500 Subject: [PATCH] Restrict integer arguments to 32 bits When built as 64-bit, use the 'i' and 'I' arguments for MiniFFI/Win32API to specifically refer to a 32-bit integer. 'l', 'L', 'n' and 'N' continue to refer to the `long` sizes. --- binding/miniffi-binding.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/binding/miniffi-binding.cpp b/binding/miniffi-binding.cpp index 01b1abc7..fc9f4ed7 100644 --- a/binding/miniffi-binding.cpp +++ b/binding/miniffi-binding.cpp @@ -3,6 +3,7 @@ #include "fake-api.h" #include +#include #include "binding-util.h" #include "debugwriter.h" @@ -251,8 +252,12 @@ RB_METHOD(MiniFFI_call) { lParam = RTEST(rb_ary_entry(args, i)); break; - case _T_NUMBER: case _T_INTEGER: +#if INTPTR_MAX == INT64_MAX + lParam = NUM2UINT(rb_ary_entry(args, i)) & UINT32_MAX; + break; +#endif + case _T_NUMBER: default: lParam = NUM2ULONG(rb_ary_entry(args, i)); break;