ruby-changes:8826
From: kazu <ko1@a...>
Date: Wed, 26 Nov 2008 13:33:34 +0900 (JST)
Subject: [ruby-changes:8826] Ruby:r20361 (ruby_1_8): * ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly.
kazu 2008-11-26 13:33:16 +0900 (Wed, 26 Nov 2008) New Revision: 20361 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20361 Log: * ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly. [ruby-dev:37182] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/ext/gdbm/gdbm.c Index: ruby_1_8/ext/gdbm/gdbm.c =================================================================== --- ruby_1_8/ext/gdbm/gdbm.c (revision 20360) +++ ruby_1_8/ext/gdbm/gdbm.c (revision 20361) @@ -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); + free(val.dptr); OBJ_TAINT(str); - return (VALUE)str; + return str; } static VALUE @@ -349,12 +345,8 @@ 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); + free(key.dptr); OBJ_TAINT(str); return str; } @@ -373,12 +365,8 @@ 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); + free(key2.dptr); OBJ_TAINT(str); return str; } Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 20360) +++ ruby_1_8/ChangeLog (revision 20361) @@ -1,3 +1,8 @@ +Wed Nov 26 13:31:07 2008 Kazuhiro NISHIYAMA <zn@m...> + + * ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly. + [ruby-dev:37182] + Tue Nov 25 16:09:36 2008 Nobuyoshi Nakada <nobu@r...> * string.c (str_independent): no independent string points null_str. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/