Skip to content

Commit b7e9a5c

Browse files
committed
Replace Renew(SvPVX(...)...) with SvPV_renew, which avoids an LVALUE
SvPVX p4raw-id: //depot/perl@24244
1 parent 8b44ba4 commit b7e9a5c

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

pp_hot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ Perl_do_readline(pTHX)
16251625
if (gimme == G_ARRAY) {
16261626
if (SvLEN(sv) - SvCUR(sv) > 20) {
16271627
SvLEN_set(sv, SvCUR(sv)+1);
1628-
Renew(SvPVX(sv), SvLEN(sv), char);
1628+
SvPV_renew(sv, SvLEN(sv));
16291629
}
16301630
sv = sv_2mortal(NEWSV(58, 80));
16311631
continue;
@@ -1635,7 +1635,7 @@ Perl_do_readline(pTHX)
16351635
const STRLEN new_len
16361636
= SvCUR(sv) < 60 ? 80 : SvCUR(sv)+40; /* allow some slop */
16371637
SvLEN_set(sv, new_len);
1638-
Renew(SvPVX(sv), SvLEN(sv), char);
1638+
SvPV_renew(sv, SvLEN(sv));
16391639
}
16401640
RETURN;
16411641
}

pp_sys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ PP(pp_backtick)
362362
XPUSHs(sv_2mortal(sv));
363363
if (SvLEN(sv) - SvCUR(sv) > 20) {
364364
SvLEN_set(sv, SvCUR(sv)+1);
365-
Renew(SvPVX(sv), SvLEN(sv), char);
365+
SvPV_renew(sv, SvLEN(sv));
366366
}
367367
SvTAINTED_on(sv);
368368
}

sv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,10 @@ in gv.h: */
793793
STMT_START { assert(SvTYPE(sv) >= SVt_PV); \
794794
(SvCUR(sv) = (val) - SvPVX(sv)); } STMT_END
795795

796+
#define SvPV_renew(sv,n) \
797+
(SvPV_set((sv), (MEM_WRAP_CHECK_(n,char) \
798+
(char*)saferealloc((Malloc_t)SvPVX(sv),(MEM_SIZE)((n))))))
799+
796800
#define BmRARE(sv) ((XPVBM*) SvANY(sv))->xbm_rare
797801
#define BmUSEFUL(sv) ((XPVBM*) SvANY(sv))->xbm_useful
798802
#define BmPREVIOUS(sv) ((XPVBM*) SvANY(sv))->xbm_previous

toke.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,7 +1826,7 @@ S_scan_const(pTHX_ char *start)
18261826
/* shrink the sv if we allocated more than we used */
18271827
if (SvCUR(sv) + 5 < SvLEN(sv)) {
18281828
SvLEN_set(sv, SvCUR(sv) + 1);
1829-
Renew(SvPVX(sv), SvLEN(sv), char);
1829+
SvPV_renew(sv, SvLEN(sv));
18301830
}
18311831

18321832
/* return the substring (via yylval) only if we parsed anything */
@@ -9604,7 +9604,7 @@ S_scan_heredoc(pTHX_ register char *s)
96049604
PL_multi_end = CopLINE(PL_curcop);
96059605
if (SvCUR(tmpstr) + 5 < SvLEN(tmpstr)) {
96069606
SvLEN_set(tmpstr, SvCUR(tmpstr) + 1);
9607-
Renew(SvPVX(tmpstr), SvLEN(tmpstr), char);
9607+
SvPV_renew(tmpstr, SvLEN(tmpstr));
96089608
}
96099609
SvREFCNT_dec(herewas);
96109610
if (!IN_BYTES) {
@@ -10080,7 +10080,7 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
1008010080
/* if we allocated too much space, give some back */
1008110081
if (SvCUR(sv) + 5 < SvLEN(sv)) {
1008210082
SvLEN_set(sv, SvCUR(sv) + 1);
10083-
Renew(SvPVX(sv), SvLEN(sv), char);
10083+
SvPV_renew(sv, SvLEN(sv));
1008410084
}
1008510085

1008610086
/* decide whether this is the first or second quoted string we've read

0 commit comments

Comments
 (0)