summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 13:08:13 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-18 13:08:13 +0000
commit21631ecabe4d09c4b5b76e35c0a0a7c84935fb8e (patch)
treef6599c99c3355ad1d32d77a7a6f8640ae94a9663
parente9fae3a2a933510d81c59dead581ddc02c8105d7 (diff)
downloadruby-21631ecabe4d09c4b5b76e35c0a0a7c84935fb8e.tar.gz
merge revision(s) 20360:20363:
* ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly. [ruby-dev:37182] * ext/gdbm/gdbm.c (rb_gdbm_nextkey): fix memory leak. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@22406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--ext/gdbm/gdbm.c26
-rw-r--r--version.h8
3 files changed, 18 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 41215cbaea..e3d3dd3ee0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Feb 18 22:07:44 2009 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * ext/gdbm/gdbm.c: do not set members of RSTRING(str) directly.
+ [ruby-dev:37182]
+
+ * ext/gdbm/gdbm.c (rb_gdbm_nextkey): fix memory leak.
+
Tue Feb 17 11:58:58 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_independent): no independent string points null_str.
diff --git a/ext/gdbm/gdbm.c b/ext/gdbm/gdbm.c
index 82109fda90..2057101206 100644
--- a/ext/gdbm/gdbm.c
+++ b/ext/gdbm/gdbm.c
@@ -303,14 +303,10 @@ rb_gdbm_fetch(dbm, key)
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 @@ rb_gdbm_firstkey(dbm)
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 @@ rb_gdbm_nextkey(dbm, keystr)
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;
}
diff --git a/version.h b/version.h
index 36bc2e3608..d8772cea39 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2009-02-17"
+#define RUBY_RELEASE_DATE "2009-02-18"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20090217
-#define RUBY_PATCHLEVEL 123
+#define RUBY_RELEASE_CODE 20090218
+#define RUBY_PATCHLEVEL 124
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];