This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Avoid potential NULL ptr dereference
[perl5.git] / regcomp.c
index c6c3a5e..8f338ae 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -20277,6 +20277,9 @@ Perl_pregfree2(pTHX_ REGEXP *rx)
 
     PERL_ARGS_ASSERT_PREGFREE2;
 
+    if (! r)
+        return;
+
     if (r->mother_re) {
         ReREFCNT_dec(r->mother_re);
     } else {
@@ -20422,6 +20425,10 @@ Perl_regfree_internal(pTHX_ REGEXP * const rx)
 
     PERL_ARGS_ASSERT_REGFREE_INTERNAL;
 
+    if (! ri) {
+        return;
+    }
+
     DEBUG_COMPILE_r({
        if (!PL_colorset)
            reginitcolors();