Bug #1452: DL::CPtr.new doesn’t check the type of the 3rd arg.
http://redmine.ruby-lang.org/issues/show/1452
e$B5/I<<Te(B: Takashi T.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$B%+%F%4%je(B: ext, Target version: 1.9.2
ruby -v: ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]
DL::CPtr.new
e$B$,0z?t$N7?$r%A%'%C%/$;$:$$$-$J$j9=B$BN$X%-%c%9%H$7$F$^$9!#e(B
e$B%Q%C%A$G$9!#e(B
$ svn diff cptr.c
Index: cptr.c
— cptr.c (e$B%j%S%8%g%se(B 23328)
+++ cptr.c (e$B:n6H%3%T!<e(B)
@@ -109,6 +109,7 @@ rb_dlptr_initialize(int argc, VALUE argv
{
VALUE ptr, sym, size;
struct ptr_data *data;
- extern VALUE rb_cDLCFunc;
void p = NULL;
freefunc_t f = NULL;
long s = 0;
@@ -124,7 +125,15 @@ rb_dlptr_initialize(int argc, VALUE argv
case 3:
p = (void)(NUM2PTR(rb_Integer(ptr)));
s = NUM2LONG(size);
- f = NIL_P(sym) ? NULL : RCFUNC_DATA(sym)->ptr;
- if (NIL_P(sym)) {
-
f = NULL;
- }
- else if (rb_obj_is_kind_of(sym, rb_cDLCFunc) == Qtrue ){
-
f = RCFUNC_DATA(sym)->ptr;
- }
- else {
-
f = NUM2PTR(rb_Integer(sym));
- }
break;
default:
rb_bug(“rb_dlptr_initialize”);