mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* marshal.c (dump_ensure), process.c (run_exec_dup2),
string.c (rb_str_replace), transcode.c (transcode_dispatch): fixed memory leaks. based on patches from shinichiro.h <shinichiro.hamaji AT gmail.com> at [ruby-dev:35751]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e231d67ee1
commit
3916eb783c
5 changed files with 16 additions and 7 deletions
|
@ -1,3 +1,10 @@
|
|||
Mon Aug 4 14:08:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* marshal.c (dump_ensure), process.c (run_exec_dup2),
|
||||
string.c (rb_str_replace), transcode.c (transcode_dispatch): fixed
|
||||
memory leaks. based on patches from shinichiro.h <shinichiro.hamaji
|
||||
AT gmail.com> at [ruby-dev:35751].
|
||||
|
||||
Sun Aug 3 19:32:52 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||
|
||||
* ext/win32ole/win32ole.c (hash2named_arg): refactoring.
|
||||
|
|
|
@ -803,6 +803,7 @@ dump_ensure(struct dump_arg *arg)
|
|||
st_free_table(arg->symbols);
|
||||
st_free_table(arg->data);
|
||||
st_free_table(arg->compat_tbl);
|
||||
if (arg->encodings) st_free_table(arg->encodings);
|
||||
DATA_PTR(arg->wrapper) = 0;
|
||||
arg->wrapper = 0;
|
||||
if (arg->taint) {
|
||||
|
|
|
@ -1953,11 +1953,11 @@ run_exec_dup2(VALUE ary, VALUE save)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
xfree(pairs);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
if (pairs)
|
||||
xfree(pairs);
|
||||
fail:
|
||||
xfree(pairs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
7
string.c
7
string.c
|
@ -3424,10 +3424,10 @@ rb_str_replace(VALUE str, VALUE str2)
|
|||
if (STR_ASSOC_P(str2)) {
|
||||
str2 = rb_str_new4(str2);
|
||||
}
|
||||
if (str_independent(str) && !STR_EMBED_P(str)) {
|
||||
xfree(RSTRING_PTR(str));
|
||||
}
|
||||
if (STR_SHARED_P(str2)) {
|
||||
if (str_independent(str) && !STR_EMBED_P(str)) {
|
||||
xfree(RSTRING_PTR(str));
|
||||
}
|
||||
STR_SET_NOEMBED(str);
|
||||
RSTRING(str)->as.heap.len = len;
|
||||
RSTRING(str)->as.heap.ptr = RSTRING_PTR(str2);
|
||||
|
@ -3436,7 +3436,6 @@ rb_str_replace(VALUE str, VALUE str2)
|
|||
RSTRING(str)->as.heap.aux.shared = RSTRING(str2)->as.heap.aux.shared;
|
||||
}
|
||||
else {
|
||||
rb_str_modify(str);
|
||||
str_replace_shared(str, rb_str_new4(str2));
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ transcode_dispatch(const char *from_encoding, const char *to_encoding)
|
|||
}
|
||||
if (!val) {
|
||||
if (!st_lookup(transcoder_table, (st_data_t)key, &val)) {
|
||||
xfree(key);
|
||||
/* multistep logic, via UTF-8 */
|
||||
if (!encoding_equal(from_encoding, "UTF-8") &&
|
||||
!encoding_equal(to_encoding, "UTF-8") &&
|
||||
|
@ -119,6 +120,7 @@ transcode_dispatch(const char *from_encoding, const char *to_encoding)
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
xfree(key);
|
||||
return (rb_transcoder *)val;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue