ruby-changes:14818
From: nobu <ko1@a...>
Date: Tue, 16 Feb 2010 19:19:46 +0900 (JST)
Subject: [ruby-changes:14818] Ruby:r26681 (trunk): * ext/dl/cfunc.c (rb_dlcfunc_call): convert signed value to
nobu 2010-02-16 19:19:24 +0900 (Tue, 16 Feb 2010) New Revision: 26681 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26681 Log: * ext/dl/cfunc.c (rb_dlcfunc_call): convert signed value to unsigned. Modified files: trunk/ChangeLog trunk/ext/dl/cfunc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 26680) +++ ChangeLog (revision 26681) @@ -1,3 +1,8 @@ +Tue Feb 16 19:19:21 2010 Nobuyoshi Nakada <nobu@r...> + + * ext/dl/cfunc.c (rb_dlcfunc_call): convert signed value to + unsigned. + Tue Feb 16 19:02:59 2010 Nobuyoshi Nakada <nobu@r...> * test/dl/test_{base,handle}.rb: use more verbose assertions. Index: ext/dl/cfunc.c =================================================================== --- ext/dl/cfunc.c (revision 26680) +++ ext/dl/cfunc.c (revision 26681) @@ -347,12 +347,21 @@ 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); } - rb_check_safe_obj(RARRAY_PTR(ary)[i]); - stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]); + else { + Check_Type(arg, T_BIGNUM); + stack[i] = rb_big2ulong_pack(arg); + } } /* calltype == CFUNC_CDECL */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/