This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.c: Handle edge case in inversion list max
authorKarl Williamson <public@khwilliamson.com>
Wed, 26 Dec 2012 17:14:34 +0000 (10:14 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 28 Dec 2012 17:38:54 +0000 (10:38 -0700)
The function _invlist_max() cannot currently be called on an inversion
list that was compiled in (via a C language array), because this edge
case is not considered.  I don't think current code ever does call this
function on this case, but that could inadvertently easily change.

regcomp.c

index ce5e9e6..aae0ad2 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7023,7 +7023,9 @@ S_invlist_max(pTHX_ SV* const invlist)
 
     PERL_ARGS_ASSERT_INVLIST_MAX;
 
-    return FROM_INTERNAL_SIZE(SvLEN(invlist));
+    return SvLEN(invlist) == 0  /* This happens under _new_invlist_C_array */
+           ? _invlist_len(invlist)
+           : FROM_INTERNAL_SIZE(SvLEN(invlist));
 }
 
 PERL_STATIC_INLINE UV*