This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Move some code to earlier
authorKarl Williamson <khw@cpan.org>
Sat, 13 Oct 2018 06:29:15 +0000 (00:29 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 20 Oct 2018 06:09:55 +0000 (00:09 -0600)
It is better defensive coding to restore as soon as possible, rather
than deferring it.

regcomp.c

index f5f48fd..17d87b6 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -16102,6 +16102,12 @@ redo_curchar:
                     NULL,
                     NULL
                 );
+
+    RExC_parse = save_parse + 1;
+    RExC_end = save_end;
+    SvREFCNT_dec_NN(final);
+    SvREFCNT_dec_NN(result_string);
+
     if (!node)
         FAIL2("panic: regclass returned failure to handle_sets, flags=%#" UVxf,
                     PTR2UV(flagp));
@@ -16136,11 +16142,6 @@ redo_curchar:
         RExC_flags |= RXf_PMf_FOLD;
     }
 
-    RExC_parse = save_parse + 1;
-    RExC_end = save_end;
-    SvREFCNT_dec_NN(final);
-    SvREFCNT_dec_NN(result_string);
-
     nextchar(pRExC_state);
     Set_Node_Length(REGNODE_p(node), RExC_parse - oregcomp_parse + 1); /* MJD */
     return node;