summaryrefslogtreecommitdiff
path: root/ext/fiddle/function.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-26 15:27:18 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-26 17:05:27 +0900
commit4949df498a4ca67234c42f00b8e2b513a6a2b6c6 (patch)
tree9b44f70614695d41d1b20dcf9f4681a0fc0df67c /ext/fiddle/function.c
parent40b40523dcf957fa9459c1c1037ad79d73867f83 (diff)
[ruby/fiddle] Fixed typos
https://github.com/ruby/fiddle/commit/a09e66adf4 https://github.com/ruby/fiddle/commit/6cab9b45d6 https://github.com/ruby/fiddle/commit/ab72b19bed
Diffstat (limited to 'ext/fiddle/function.c')
-rw-r--r--ext/fiddle/function.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 994402e26b..b624255f27 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -93,7 +93,7 @@ initialize(int argc, VALUE argv[], VALUE self)
ffi_cif * cif;
ffi_type **arg_types, *rtype;
ffi_status result;
- VALUE ptr, args, ret_type, abi, kwds, ary;
+ VALUE ptr, args, ret_type, abi, kwds;
int i, len;
int nabi;
void *cfunc;
@@ -113,14 +113,15 @@ initialize(int argc, VALUE argv[], VALUE self)
Check_Type(args, T_ARRAY);
len = RARRAY_LENINT(args);
Check_Max_Args("args", len);
- ary = rb_ary_subseq(args, 0, len);
+ /* freeze to prevent inconsistency at calling #to_int later */
+ args = rb_ary_subseq(args, 0, len);
for (i = 0; i < RARRAY_LEN(args); i++) {
VALUE a = RARRAY_AREF(args, i);
int type = NUM2INT(a);
(void)INT2FFI_TYPE(type); /* raise */
- if (INT2FIX(type) != a) rb_ary_store(ary, i, INT2FIX(type));
+ if (INT2FIX(type) != a) rb_ary_store(args, i, INT2FIX(type));
}
- OBJ_FREEZE(ary);
+ OBJ_FREEZE(args);
rb_iv_set(self, "@ptr", ptr);
rb_iv_set(self, "@args", args);