This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Add assertions
authorKarl Williamson <khw@cpan.org>
Thu, 14 Mar 2019 23:06:16 +0000 (17:06 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 14 Mar 2019 23:12:26 +0000 (17:12 -0600)
These make sure we don't exceed the 32 bits available for long jumps.

regcomp.c

index 73e8a83..5f2c863 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -19673,6 +19673,7 @@ S_regtail(pTHX_ RExC_state_t * pRExC_state,
     }
 
     if (reg_off_by_arg[OP(REGNODE_p(scan))]) {
+        assert(val - scan <= U32_MAX);
         ARG_SET(REGNODE_p(scan), val - scan);
     }
     else {
@@ -19784,6 +19785,7 @@ S_regtail_study(pTHX_ RExC_state_t *pRExC_state, regnode_offset p,
         );
     });
     if (reg_off_by_arg[OP(REGNODE_p(scan))]) {
+        assert(val - scan <= U32_MAX);
        ARG_SET(REGNODE_p(scan), val - scan);
     }
     else {