From ea725ce6fd46ebc3bd7040373b9c0721af8813f8 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Tue, 17 May 2011 12:28:36 +0100 Subject: [PATCH] In Perl_fbm_compile(), use STRLEN instead of U32 to calculate BmPREVIOUS(). This should fix a theoretical bug on strings longer than 2**32 bytes where the byte referenced by BmRARE() is at an offset beyond 2**32. I'm not sure how to test this, as I think to trigger it one would need to have one of a: the second argument to index as a string literal, longer than 2**32 bytes b: a fixed string in a regex, longer than 2**32 bytes --- util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/util.c b/util.c index 1111ff1..7341117 100644 --- a/util.c +++ b/util.c @@ -545,9 +545,9 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags) { dVAR; register const U8 *s; - register U32 i; + STRLEN i; STRLEN len; - U32 rarest = 0; + STRLEN rarest = 0; U32 frequency = 256; PERL_ARGS_ASSERT_FBM_COMPILE; @@ -606,8 +606,8 @@ Perl_fbm_compile(pTHX_ SV *sv, U32 flags) BmUSEFUL(sv) = 100; /* Initial value */ if (flags & FBMcf_TAIL) SvTAIL_on(sv); - DEBUG_r(PerlIO_printf(Perl_debug_log, "rarest char %c at %lu\n", - BmRARE(sv),(unsigned long)BmPREVIOUS(sv))); + DEBUG_r(PerlIO_printf(Perl_debug_log, "rarest char %c at %"UVuf"\n", + BmRARE(sv), BmPREVIOUS(sv))); } /* If SvTAIL(littlestr), it has a fake '\n' at end. */ -- 1.8.3.1