summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-05-17 12:28:36 +0100
committerNicholas Clark <nick@ccl4.org>2011-06-11 09:40:02 +0200
commitea725ce6fd46ebc3bd7040373b9c0721af8813f8 (patch)
tree7bbd6d6b3f4eb5ff6b980645959f8ab7843d5de4 /util.c
parentced454951435adad2176a9e62dc76e463b1a6406 (diff)
downloadperl-ea725ce6fd46ebc3bd7040373b9c0721af8813f8.tar.gz
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
Diffstat (limited to 'util.c')
-rw-r--r--util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/util.c b/util.c
index 1111ff1a78..7341117176 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. */