Project

General

Profile

Actions

Bug #1452

closed

DL::CPtr.new doesn't check the type of the 3rd arg.

Added by sheepman (Takashi Tamura) almost 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2009-05-02 trunk 23326) [i686-linux]
Backport:
[ruby-dev:38403]

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
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23385.
=end

Actions

Also available in: Atom PDF

Like0
Like0