diff options
author | Karl Williamson <khw@cpan.org> | 2016-03-07 15:37:11 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-03-17 21:47:16 -0600 |
commit | cc93400aa5a8d556c56c28a8de644bd178d050d4 (patch) | |
tree | 7afa5977203d9d9d792092caf9716439e17634ec /regcomp.c | |
parent | bc604ad8779b0724bcb3adec1938d7858873ee2f (diff) | |
download | perl-cc93400aa5a8d556c56c28a8de644bd178d050d4.tar.gz |
regcomp.c: Avoid a memory leak
I spotted this in code reading. The chances of it happening are quite
small. It could happen under tainting with a user-defined \p{}
property, and /i matching.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -15986,6 +15986,10 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, SAVEFREEPV(name); if (FOLD) { lookup_name = savepv(Perl_form(aTHX_ "__%s_i", name)); + + /* The function call just below that uses this can fail + * to return, leaking memory if we don't do this */ + SAVEFREEPV(lookup_name); } /* Look up the property name, and get its swash and @@ -16001,9 +16005,6 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth, NULL, /* No inversion list */ &swash_init_flags ); - if (lookup_name) { - Safefree(lookup_name); - } if (! swash || ! (invlist = _get_swash_invlist(swash))) { HV* curpkg = (IN_PERL_COMPILETIME) ? PL_curstash |