From: Nicholas Clark Date: Mon, 18 Apr 2005 20:37:13 +0000 (+0000) Subject: Replace Renew(SvPVX(...)...) with SvPV_renew, which avoids an LVALUE X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b7e9a5c2d751f7ed3b8a703e57ac933ded5b16ce;p=p5sagit%2Fp5-mst-13.2.git Replace Renew(SvPVX(...)...) with SvPV_renew, which avoids an LVALUE SvPVX p4raw-id: //depot/perl@24244 --- diff --git a/pp_hot.c b/pp_hot.c index 1a23c90..64c4fec 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -1625,7 +1625,7 @@ Perl_do_readline(pTHX) if (gimme == G_ARRAY) { if (SvLEN(sv) - SvCUR(sv) > 20) { SvLEN_set(sv, SvCUR(sv)+1); - Renew(SvPVX(sv), SvLEN(sv), char); + SvPV_renew(sv, SvLEN(sv)); } sv = sv_2mortal(NEWSV(58, 80)); continue; @@ -1635,7 +1635,7 @@ Perl_do_readline(pTHX) const STRLEN new_len = SvCUR(sv) < 60 ? 80 : SvCUR(sv)+40; /* allow some slop */ SvLEN_set(sv, new_len); - Renew(SvPVX(sv), SvLEN(sv), char); + SvPV_renew(sv, SvLEN(sv)); } RETURN; } diff --git a/pp_sys.c b/pp_sys.c index 16f539b..9d31e81 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -362,7 +362,7 @@ PP(pp_backtick) XPUSHs(sv_2mortal(sv)); if (SvLEN(sv) - SvCUR(sv) > 20) { SvLEN_set(sv, SvCUR(sv)+1); - Renew(SvPVX(sv), SvLEN(sv), char); + SvPV_renew(sv, SvLEN(sv)); } SvTAINTED_on(sv); } diff --git a/sv.h b/sv.h index 07a0296..511b547 100644 --- a/sv.h +++ b/sv.h @@ -793,6 +793,10 @@ in gv.h: */ STMT_START { assert(SvTYPE(sv) >= SVt_PV); \ (SvCUR(sv) = (val) - SvPVX(sv)); } STMT_END +#define SvPV_renew(sv,n) \ + (SvPV_set((sv), (MEM_WRAP_CHECK_(n,char) \ + (char*)saferealloc((Malloc_t)SvPVX(sv),(MEM_SIZE)((n)))))) + #define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare #define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful #define BmPREVIOUS(sv) ((XPVBM*) SvANY(sv))->xbm_previous diff --git a/toke.c b/toke.c index a4898a2..5518078 100644 --- a/toke.c +++ b/toke.c @@ -1826,7 +1826,7 @@ S_scan_const(pTHX_ char *start) /* shrink the sv if we allocated more than we used */ if (SvCUR(sv) + 5 < SvLEN(sv)) { SvLEN_set(sv, SvCUR(sv) + 1); - Renew(SvPVX(sv), SvLEN(sv), char); + SvPV_renew(sv, SvLEN(sv)); } /* return the substring (via yylval) only if we parsed anything */ @@ -9604,7 +9604,7 @@ retval: PL_multi_end = CopLINE(PL_curcop); if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) { SvLEN_set(tmpstr, SvCUR(tmpstr) + 1); - Renew(SvPVX(tmpstr), SvLEN(tmpstr), char); + SvPV_renew(tmpstr, SvLEN(tmpstr)); } SvREFCNT_dec(herewas); if (!IN_BYTES) { @@ -10080,7 +10080,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims) /* if we allocated too much space, give some back */ if (SvCUR(sv) + 5 < SvLEN(sv)) { SvLEN_set(sv, SvCUR(sv) + 1); - Renew(SvPVX(sv), SvLEN(sv), char); + SvPV_renew(sv, SvLEN(sv)); } /* decide whether this is the first or second quoted string we've read