From b5c043e0cad70790d336af80b1320083742da756 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 6 Mar 2023 14:41:59 +0100 Subject: Increment callbackCount outside of the macro RB_OBJ_WRITE .. to ensure it is called exactly once. --- ext/ffi_c/FunctionInfo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/ffi_c/FunctionInfo.c b/ext/ffi_c/FunctionInfo.c index e3391c3..6aa93d9 100644 --- a/ext/ffi_c/FunctionInfo.c +++ b/ext/ffi_c/FunctionInfo.c @@ -183,7 +183,8 @@ fntype_initialize(int argc, VALUE* argv, VALUE self) if (rb_obj_is_kind_of(type, rbffi_FunctionTypeClass)) { REALLOC_N(fnInfo->callbackParameters, VALUE, fnInfo->callbackCount + 1); - RB_OBJ_WRITE(self, &fnInfo->callbackParameters[fnInfo->callbackCount++], type); + RB_OBJ_WRITE(self, &fnInfo->callbackParameters[fnInfo->callbackCount], type); + fnInfo->callbackCount++; } if (rb_obj_is_kind_of(type, rbffi_StructByValueClass)) { -- cgit v1.2.1