summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/dl/cfunc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index 2c0cd5f240..aa744d26ec 100644
--- a/ext/dl/cfunc.c
+++ b/ext/dl/cfunc.c
@@ -347,12 +347,21 @@ rb_dlcfunc_call(VALUE self, VALUE ary)
return Qnil;
}
+ if( RARRAY_LEN(ary) >= DLSTACK_SIZE ){
+ rb_raise(rb_eDLError, "too many arguments (stack overflow)");
+ }
for( i = 0; i < RARRAY_LEN(ary); i++ ){
- if( i >= DLSTACK_SIZE ){
- rb_raise(rb_eDLError, "too many arguments (stack overflow)");
+ unsigned long rb_big2ulong_pack(VALUE x);
+ VALUE arg = RARRAY_PTR(ary)[i];
+
+ rb_check_safe_obj(arg);
+ if (FIXNUM_P(arg)) {
+ stack[i] = FIX2LONG(arg);
+ }
+ else {
+ Check_Type(arg, T_BIGNUM);
+ stack[i] = rb_big2ulong_pack(arg);
}
- rb_check_safe_obj(RARRAY_PTR(ary)[i]);
- stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
}
/* calltype == CFUNC_CDECL */