This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Replace invalid assertion
authorKarl Williamson <khw@cpan.org>
Wed, 10 Feb 2016 18:28:58 +0000 (11:28 -0700)
committerKarl Williamson <khw@cpan.org>
Thu, 11 Feb 2016 04:16:44 +0000 (21:16 -0700)
A future commit shows that this assertion is not valid.  I don't know
how it can currently be triggered, but fix the code to properly handle
the case.

regcomp.c

index cc80e1b..66cffd4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -8629,7 +8629,10 @@ Perl__invlist_search(SV* const invlist, const UV cp)
     array = invlist_array(invlist);
 
     mid = invlist_previous_index(invlist);
-    assert(mid >=0 && mid <= highest_element);
+    assert(mid >=0);
+    if (mid > highest_element) {
+        mid = highest_element;
+    }
 
     /* <mid> contains the cache of the result of the previous call to this
      * function (0 the first time).  See if this call is for the same result,