diff options
author | David Mitchell <davem@iabyn.com> | 2017-06-01 16:05:59 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2017-06-07 09:11:08 +0100 |
commit | e5c237c4457bb568c86126cf3816b5c115cba1b2 (patch) | |
tree | 120661b68a76414fdad485b926cdd80bddb24e94 /sv.c | |
parent | cf939a2ec7d3e073ec2ba5651369050b230f5156 (diff) | |
download | perl-e5c237c4457bb568c86126cf3816b5c115cba1b2.tar.gz |
Perl_sv_vcatpvfn_flags: eliminate a wrap check
This is one case where it can never wrap, so don't check.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 17 |
1 files changed, 5 insertions, 12 deletions
@@ -13259,18 +13259,11 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p /* signed value that's wrapped? */ assert(elen <= ((~(STRLEN)0) >> 1)); - /* Most of these length vars can range to any value if - * supplied with a hostile format and/or args. So check every - * addition for possible overflow. In reality some of these - * values are interdependent so these checks are slightly - * redundant. But its easier to be certain this way. - */ - - have = elen; - - if (have >= (((STRLEN)~0) - zeros)) - croak_memory_wrap(); - have += zeros; + /* if zeros is non-zero, then it represents filler between + * elen and precis. So adding elen and zeros together will + * always be <= precis, and the addition can never wrap */ + assert(!zeros || (precis > elen && precis - elen == zeros)); + have = elen + zeros; if (have >= (((STRLEN)~0) - esignlen)) croak_memory_wrap(); |