This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix #78266: Memory leak with named regexp captures.
[perl5.git] / regcomp.c
index b1b8e6f..9e9fac4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -5418,6 +5418,10 @@ Perl_reg_named_buff_fetch(pTHX_ REGEXP * const r, SV * const namesv,
                 return newRV_noinc(MUTABLE_SV(retarray));
         }
     }
+
+    if (ret)
+        SvREFCNT_dec(ret);
+
     return NULL;
 }