ruby-changes:13738
From: yugui <ko1@a...>
Date: Wed, 28 Oct 2009 23:10:26 +0900 (JST)
Subject: [ruby-changes:13738] Ruby:r25531 (ruby_1_9_1): merges r24550,r24551 and r24552 from trunk into ruby_1_9_1.
yugui 2009-10-28 23:10:11 +0900 (Wed, 28 Oct 2009) New Revision: 25531 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25531 Log: merges r24550,r24551 and r24552 from trunk into ruby_1_9_1. -- * regparse.c (parse_char_class, parse_exp, parse_branch), (parse_subexp): fixed memory leak. a patch from Ralf Junker <ralfjunker AT gmx.de> at [ruby-core:24921]. -- * regparse.c: commit miss. -- * regparse.c: commit miss again. Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/regparse.c branches/ruby_1_9_1/version.h Index: ruby_1_9_1/regparse.c =================================================================== --- ruby_1_9_1/regparse.c (revision 25530) +++ ruby_1_9_1/regparse.c (revision 25531) @@ -1,3 +1,4 @@ +/* -*- mode:c; c-file-style:"gnu" -*- */ /********************************************************************** regparse.c - Oniguruma (regular expression library) **********************************************************************/ @@ -4403,12 +4404,11 @@ CClassNode* acc; r = parse_char_class(&anode, tok, &p, end, env); - if (r != 0) goto cc_open_err; - acc = NCCLASS(anode); - r = or_cclass(cc, acc, env->enc); - + if (r == 0) { + acc = NCCLASS(anode); + r = or_cclass(cc, acc, env); + } onig_node_free(anode); - cc_open_err: if (r != 0) goto err; } break; @@ -4497,7 +4497,6 @@ err: if (cc != NCCLASS(*np)) bbuf_free(cc->mbuf); - onig_node_free(*np); return r; } @@ -4731,7 +4730,10 @@ r = fetch_token(tok, &p, end, env); if (r < 0) return r; r = parse_subexp(&target, tok, term, &p, end, env); - if (r < 0) return r; + if (r < 0) { + onig_node_free(target); + return r; + } if (NTYPE(*np) == NT_ANCHOR) NANCHOR(*np)->target = target; @@ -5054,9 +5056,8 @@ case TK_ALT: case TK_EOT: end_of_token: - *np = node_new_empty(); - return tok->type; - break; + *np = node_new_empty(); + return tok->type; case TK_SUBEXP_OPEN: r = parse_enclose(np, tok, TK_SUBEXP_CLOSE, src, end, env); @@ -5071,8 +5072,11 @@ if (r < 0) return r; r = parse_subexp(&target, tok, term, src, end, env); env->option = prev; - if (r < 0) return r; - NENCLOSE(*np)->target = target; + if (r < 0) { + onig_node_free(target); + return r; + } + NENCLOSE(*np)->target = target; return tok->type; } break; @@ -5386,7 +5390,7 @@ NQTFR(qn)->greedy = tok->u.repeat.greedy; r = set_quantifier(qn, *targetp, group, env); if (r < 0) return r; - + if (tok->u.repeat.possessive != 0) { Node* en; en = node_new_enclose(ENCLOSE_STOP_BACKTRACK); @@ -5429,7 +5433,10 @@ *top = NULL; r = parse_exp(&node, tok, term, src, end, env); - if (r < 0) return r; + if (r < 0) { + onig_node_free(node); + return r; + } if (r == TK_EOT || r == term || r == TK_ALT) { *top = node; @@ -5439,7 +5446,10 @@ headp = &(NCDR(*top)); while (r != TK_EOT && r != term && r != TK_ALT) { r = parse_exp(&node, tok, term, src, end, env); - if (r < 0) return r; + if (r < 0) { + onig_node_free(node); + return r; + } if (NTYPE(node) == NT_LIST) { *headp = node; @@ -5481,7 +5491,10 @@ r = fetch_token(tok, src, end, env); if (r < 0) return r; r = parse_branch(&node, tok, term, src, end, env); - if (r < 0) return r; + if (r < 0) { + onig_node_free(node); + return r; + } *headp = onig_node_new_alt(node, NULL); headp = &(NCDR(*headp)); @@ -5491,6 +5504,7 @@ goto err; } else { + onig_node_free(node); err: if (term == TK_SUBEXP_CLOSE) return ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS; Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 25530) +++ ruby_1_9_1/ChangeLog (revision 25531) @@ -1,3 +1,9 @@ +Sun Aug 16 10:45:10 2009 Nobuyoshi Nakada <nobu@r...> + + * regparse.c (parse_char_class, parse_exp, parse_branch), + (parse_subexp): fixed memory leak. a patch from Ralf Junker + <ralfjunker AT gmx.de> at [ruby-core:24921]. + Sun Aug 16 01:10:00 2009 NARUSE, Yui <naruse@r...> * regparse.c (add_ctype_to_cc_by_range): fix the first Index: ruby_1_9_1/version.h =================================================================== --- ruby_1_9_1/version.h (revision 25530) +++ ruby_1_9_1/version.h (revision 25531) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.1" -#define RUBY_PATCHLEVEL 291 +#define RUBY_PATCHLEVEL 292 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/