From b8f74c7b234a0830ee01bbcaa2050f67244f6590 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Fri, 2 Mar 2018 10:19:57 +0900 Subject: [PATCH] free node for error cases --- src/regparse.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/regparse.c b/src/regparse.c index aa55322..f5cfb2b 100644 --- a/src/regparse.c +++ b/src/regparse.c @@ -6519,16 +6519,15 @@ parse_callout_of_contents(Node** np, int cterm, UChar** src, UChar* end, ScanEnv r = reg_callout_list_entry(env, &num); if (r != 0) return r; - r = node_new_callout(np, ONIG_CALLOUT_OF_CONTENTS, num, ONIG_NO_NAME_ID, 0, env); - if (r != 0) return r; - ext = onig_get_regex_ext(env->reg); - CHECK_NULL_RETURN_MEMERR(ext); if (IS_NULL(ext->pattern)) { r = onig_ext_set_pattern(env->reg, env->pattern, env->pattern_end); if (r != ONIG_NORMAL) return r; } + r = node_new_callout(np, ONIG_CALLOUT_OF_CONTENTS, num, ONIG_NO_NAME_ID, 0, env); + if (r != 0) return r; + e = onig_reg_callout_list_at(env->reg, num); e->of = ONIG_CALLOUT_OF_CONTENTS; e->in = in; @@ -6821,6 +6820,12 @@ parse_callout_of_name(Node** np, int cterm, UChar** src, UChar* end, ScanEnv* en r = reg_callout_list_entry(env, &num); if (r != 0) return r; + ext = onig_get_regex_ext(env->reg); + if (IS_NULL(ext->pattern)) { + r = onig_ext_set_pattern(env->reg, env->pattern, env->pattern_end); + if (r != ONIG_NORMAL) return r; + } + r = node_new_callout(&node, ONIG_CALLOUT_OF_NAME, num, name_id, with_tag, env); if (r != ONIG_NORMAL) return r; @@ -6832,13 +6837,6 @@ parse_callout_of_name(Node** np, int cterm, UChar** src, UChar* end, ScanEnv* en } } - ext = onig_get_regex_ext(env->reg); - CHECK_NULL_RETURN_MEMERR(ext); - if (IS_NULL(ext->pattern)) { - r = onig_ext_set_pattern(env->reg, env->pattern, env->pattern_end); - if (r != ONIG_NORMAL) return r; - } - e = onig_reg_callout_list_at(env->reg, num); e->of = ONIG_CALLOUT_OF_NAME; e->in = in; -- 2.40.0