[Bug:1.8] RSTRING in ext/gdbm/gdbm.c


#1

e$B@>;3OB9-$G$9!#e(B

[ruby-core:20082]e$B$K$R$C$+$+$C$?$N$G!"$H$j$"$($:e(B

Index: object.c

— object.c(revision 20352)
+++ object.c(working copy)
@@ -223,7 +223,7 @@
}
clone = rb_obj_alloc(rb_obj_class(obj));
RBASIC(clone)->klass = rb_singleton_class_clone(obj);

  • RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone,
    FL_TAINT)) & ~(FL_FREEZE|FL_FINALIZE);
  • RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone,
    FL_TAINT|ELTS_SHARED)) & ~(FL_FREEZE|FL_FINALIZE);
    init_copy(clone, obj);
    RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE;

e$B$H$7$F2sHr$7$F$$?$H$3$m!"e(Bgdbme$B$N%F%9%H$NCf$GMn$A$k$h$&$K$J$C$?$N$G!"e(B
e$BD4$Y$F$
$?$H$3$m!“e(Brb_str_s_alloce$B$Ge(BELTS_SHAREDe$B$,@_Dj$5$l$F$$$k$N$Ke(B
aux.sharede$B$rL5;k$7$Fe(Baux.capae$B$r@_Dj$7$F$$$F!”$=$l$r8e$Ge(B
RSTRING(aux.shared)e$B$G;2>H$5$l$F$7$^$&$N$,860x$@$H$o$+$j$^$7$?!#e(B

e$B0J2<$N$h$&$K$7$?J}$,NI$$$H;W$C$?$N$G$9$,!"$I$&$G$7$g$&$+e(B?

Index: ext/gdbm/gdbm.c

— ext/gdbm/gdbm.c(revision 20352)
+++ ext/gdbm/gdbm.c(working copy)
@@ -303,12 +303,7 @@
if (val.dptr == 0)
return Qnil;

  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = val.dsize;
  • RSTRING(str)->aux.capa = val.dsize;
  • RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1);
  • RSTRING(str)->ptr[val.dsize] = ‘\0’;
  • str = rb_str_new(val.dptr, val.dsize);
    OBJ_TAINT(str);
    return (VALUE)str;
    }
    @@ -349,12 +344,7 @@
    if (key.dptr == 0)
    return Qnil;
  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = key.dsize;
  • RSTRING(str)->aux.capa = key.dsize;
  • RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1);
  • RSTRING(str)->ptr[RSTRING(str)->len] = ‘\0’;
  • str = rb_str_new(key.dptr, key.dsize);
    OBJ_TAINT(str);
    return str;
    }
    @@ -373,12 +363,7 @@
    if (key2.dptr == 0)
    return Qnil;
  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = key2.dsize;
  • RSTRING(str)->aux.capa = key2.dsize;
  • RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);
  • RSTRING(str)->ptr[RSTRING(str)->len] = ‘\0’;
  • str = rb_str_new(key2.dptr, key2.dsize);
    OBJ_TAINT(str);
    return str;
    }

#2

e$B@>;3OB9-$G$9!#e(B

e$B@h$[$I$N%Q%C%A$G$Oe(Bdptre$B$,%a%b%j%j!<%/$9$k$h$&$K$J$C$F$7$^$C$F$$$?$N$G!"e(B
e$B=$@5$7$^$7$?!#e(B

Index: ext/gdbm/gdbm.c

— ext/gdbm/gdbm.c(revision 20353)
+++ ext/gdbm/gdbm.c(working copy)
@@ -303,14 +303,10 @@
if (val.dptr == 0)
return Qnil;

  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = val.dsize;
  • RSTRING(str)->aux.capa = val.dsize;
  • RSTRING(str)->ptr = REALLOC_N(val.dptr,char,val.dsize+1);
  • RSTRING(str)->ptr[val.dsize] = ‘\0’;
  • str = rb_str_new(val.dptr, val.dsize);
    OBJ_TAINT(str);
  • return (VALUE)str;
  • free(val.dptr);
  • return str;
    }

static VALUE
@@ -349,13 +345,9 @@
if (key.dptr == 0)
return Qnil;

  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = key.dsize;
  • RSTRING(str)->aux.capa = key.dsize;
  • RSTRING(str)->ptr = REALLOC_N(key.dptr,char,key.dsize+1);
  • RSTRING(str)->ptr[RSTRING(str)->len] = ‘\0’;
  • str = rb_str_new(key.dptr, key.dsize);
    OBJ_TAINT(str);
  • free(key.dptr);
    return str;
    }

@@ -373,13 +365,9 @@
if (key2.dptr == 0)
return Qnil;

  • str = rb_obj_alloc(rb_cString);
  • RSTRING(str)->len = key2.dsize;
  • RSTRING(str)->aux.capa = key2.dsize;
  • RSTRING(str)->ptr = REALLOC_N(key2.dptr,char,key2.dsize+1);
  • RSTRING(str)->ptr[RSTRING(str)->len] = ‘\0’;
  • str = rb_str_new(key2.dptr, key2.dsize);
    OBJ_TAINT(str);
  • free(key2.dptr);
    return str;
    }

#3

e$B%A%1%C%He(B #789 e$B$,99?7$5$l$^$7$?!#e(B (by Anonymous)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r20361.

http://redmine.ruby-lang.org/issues/show/789