summaryrefslogtreecommitdiff
path: root/ext/dl
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-16 10:19:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-16 10:19:24 +0000
commit4d71618c3888f841b3f2242e95f9b2a702807f03 (patch)
tree17dda3a88cd7985958d499da70335486e6de557f /ext/dl
parentda2497745e207c20b632ec14731397fb48a52fd2 (diff)
* ext/dl/cfunc.c (rb_dlcfunc_call): convert signed value to
unsigned. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl')
-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 2c0cd5f..aa744d2 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 */