Actions
Bug #1452
closedDL::CPtr.new doesn't check the type of the 3rd arg.
    Bug #1452:
    DL::CPtr.new doesn't check the type of the 3rd arg.
  
Description
=begin
DL::CPtr.new が引数の型をチェックせずいきなり構造体へキャストしてます。
パッチです。
$ svn diff cptr.c
Index: cptr.c¶
--- cptr.c      (リビジョン 23328)
+++ cptr.c      (作業コピー)
@@ -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");
 =end
        
           Updated by nobu (Nobuyoshi Nakada) over 16 years ago
          Updated by nobu (Nobuyoshi Nakada) over 16 years ago
          
          
        
        
      
      - Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23385.
=end
Actions