From 24044fabd839afe7d01d53cc50f06415298d31ec Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 1 Nov 2012 13:08:17 -0700 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20leak=20with=20/(=3F{})$invalid?= =?utf8?q?=5Fcode=5Fblock/?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This script was leaking: $ ./perl -Ilib -wMre=eval -e '$x = "(?{+})"; while(1){eval {/(?{})$x/}}' The mallocked array that is allocated before compilation to hold the code blocks was not being freed before the syntax error from the inner pattern ($x) was propagated. --- regcomp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/regcomp.c b/regcomp.c index ef380ab..3bd8475 100644 --- a/regcomp.c +++ b/regcomp.c @@ -5096,7 +5096,10 @@ S_compile_runtime_code(pTHX_ RExC_state_t * const pRExC_state, qr_ref = POPs; PUTBACK; if (SvTRUE(ERRSV)) + { + Safefree(pRExC_state->code_blocks); Perl_croak(aTHX_ "%s", SvPVx_nolen_const(ERRSV)); + } assert(SvROK(qr_ref)); qr = SvRV(qr_ref); assert(SvTYPE(qr) == SVt_REGEXP && RX_ENGINE((REGEXP*)qr)->op_comp); -- 2.7.4