summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-03-06 14:41:59 +0100
committerLars Kanis <lars@greiz-reinsdorf.de>2023-03-06 14:47:02 +0100
commitb5c043e0cad70790d336af80b1320083742da756 (patch)
treec7e889ea9dcc2182ba03630ae762bb6077205beb
parent99046c1852786fc3b23f3a5381b50bfe6caee798 (diff)
downloadffi-b5c043e0cad70790d336af80b1320083742da756.tar.gz
Increment callbackCount outside of the macro RB_OBJ_WRITE
.. to ensure it is called exactly once.
-rw-r--r--ext/ffi_c/FunctionInfo.c3
1 files changed, 2 insertions, 1 deletions
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)) {