This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toke.c: Add assertion
authorKarl Williamson <khw@cpan.org>
Wed, 10 Apr 2019 18:54:30 +0000 (12:54 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 10 Apr 2019 19:44:24 +0000 (13:44 -0600)
toke.c

diff --git a/toke.c b/toke.c
index 5477662..3add418 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2965,6 +2965,11 @@ S_scan_const(pTHX_ char *start)
     ENTER_with_name("scan_const");
     SAVEFREESV(sv);
 
     ENTER_with_name("scan_const");
     SAVEFREESV(sv);
 
+    /* A bunch of code in the loop below assumes that if s[n] exists and is not
+     * NUL, then s[n+1] exists.  This assertion makes sure that assumption is
+     * valid */
+    assert(*send == '\0');
+
     while (s < send
            || dorange   /* Handle tr/// range at right edge of input */
     ) {
     while (s < send
            || dorange   /* Handle tr/// range at right edge of input */
     ) {