summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--ext/dl/cfunc.c17
2 files changed, 18 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 96e7535c01f..271159226cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 16 19:19:21 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/dl/cfunc.c (rb_dlcfunc_call): convert signed value to
+ unsigned.
+
Tue Feb 16 19:02:59 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/dl/test_{base,handle}.rb: use more verbose assertions.
diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c
index 2c0cd5f2409..aa744d26ec6 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 */