diff options
author | Yves Orton <demerphq@gmail.com> | 2016-04-08 21:25:20 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2016-04-08 21:30:50 +0200 |
commit | bcc9f606509ad2fad50e16f081103451b7dc49e1 (patch) | |
tree | a6db50d6af82c1b496504bf7e80902d0ebf66f0b /sv.h | |
parent | e19cb11142087974d956f263d24e146b968025d5 (diff) | |
download | perl-bcc9f606509ad2fad50e16f081103451b7dc49e1.tar.gz |
More generalized fix for #127855, overallocate in SvGROW and not just sv_grow()
If we overallocate in SvGROW() and not just sv_grow() we can ensure
we have more cases where we can COW. We need to ensure we always
have room for a null and a reference count.
Diffstat (limited to 'sv.h')
-rw-r--r-- | sv.h | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -2111,12 +2111,15 @@ See also C<L</PL_sv_yes>> and C<L</PL_sv_no>>. #ifdef PERL_ANY_COW # define SvGROW(sv,len) \ - (SvIsCOW(sv) || SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv)) + (SvIsCOW(sv) || SvLEN(sv) < ((len)+2) ? sv_grow(sv,(len)+2) : SvPVX(sv)) +# define SvGROW_mutable(sv,len) \ + (SvLEN(sv) < ((len)+2) ? sv_grow(sv,(len)+2) : SvPVX_mutable(sv)) #else -# define SvGROW(sv,len) (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX(sv)) +# define SvGROW(sv,len) \ + (SvLEN(sv) < ((len)+1) ? sv_grow(sv,(len)+1) : SvPVX(sv)) +# define SvGROW_mutable(sv,len) \ + (SvLEN(sv) < ((len)+1) ? sv_grow(sv,(len)+1) : SvPVX_mutable(sv)) #endif -#define SvGROW_mutable(sv,len) \ - (SvLEN(sv) < (len) ? sv_grow(sv,len) : SvPVX_mutable(sv)) #define Sv_Grow sv_grow #define CLONEf_COPY_STACKS 1 |