summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 */