summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-06-10 20:48:35 +0000
committerNicholas Clark <nick@ccl4.org>2005-06-10 20:48:35 +0000
commit93524f2be2dba9389167a137d53a88545322b55e (patch)
treebe092e7b27a41cc50a20a34ed87bfed6c68842d9
parentda9e634887501d86e4a653cbb4bbc6b2d723c303 (diff)
downloadperl-93524f2be2dba9389167a137d53a88545322b55e.tar.gz
Move SvPV consting, remove an n_a, and correct one error in Move()
p4raw-id: //depot/perl@24798
-rw-r--r--doio.c35
-rw-r--r--doop.c10
-rw-r--r--dump.c18
-rw-r--r--op.c12
-rw-r--r--sv.c66
5 files changed, 71 insertions, 70 deletions
diff --git a/doio.c b/doio.c
index 79ca1fd174..cafa43566a 100644
--- a/doio.c
+++ b/doio.c
@@ -852,7 +852,8 @@ Perl_nextargv(pTHX_ register GV *gv)
do_close(gv,FALSE);
(void)PerlLIO_unlink(SvPVX_const(sv));
(void)PerlLIO_rename(PL_oldname,SvPVX_const(sv));
- do_open(gv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,O_RDONLY,0,Nullfp);
+ do_open(gv,(char*)SvPVX_const(sv),SvCUR(sv),PL_inplace!=0,
+ O_RDONLY,0,Nullfp);
#endif /* DOSISH */
#else
(void)UNLINK(SvPVX_const(sv));
@@ -888,11 +889,12 @@ Perl_nextargv(pTHX_ register GV *gv)
sv_catpvn(sv,PL_oldname,oldlen);
SETERRNO(0,0); /* in case sprintf set errno */
#ifdef VMS
- if (!do_open(PL_argvoutgv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,
- O_WRONLY|O_CREAT|O_TRUNC,0,Nullfp))
+ if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv),
+ PL_inplace!=0,O_WRONLY|O_CREAT|O_TRUNC,0,Nullfp))
#else
- if (!do_open(PL_argvoutgv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,
- O_WRONLY|O_CREAT|OPEN_EXCL,0666,Nullfp))
+ if (!do_open(PL_argvoutgv,(char*)SvPVX_const(sv),SvCUR(sv),
+ PL_inplace!=0,O_WRONLY|O_CREAT|OPEN_EXCL,0666,
+ Nullfp))
#endif
{
if (ckWARN_d(WARN_INPLACE))
@@ -2056,14 +2058,14 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
if (infosize)
{
- STRLEN len;
if (getinfo)
{
- SvPV_force(astr, len);
+ SvPV_force_nolen(astr);
a = SvGROW(astr, infosize+1);
}
else
{
+ STRLEN len;
a = SvPV(astr, len);
if (len != infosize)
Perl_croak(aTHX_ "Bad arg length for %s, is %lu, should be %ld",
@@ -2121,7 +2123,7 @@ Perl_do_msgsnd(pTHX_ SV **mark, SV **sp)
{
#ifdef HAS_MSG
SV *mstr;
- char *mbuf;
+ const char *mbuf;
I32 msize, flags;
STRLEN len;
const I32 id = SvIVx(*++mark);
@@ -2129,7 +2131,7 @@ Perl_do_msgsnd(pTHX_ SV **mark, SV **sp)
mstr = *++mark;
flags = SvIVx(*++mark);
- mbuf = SvPV(mstr, len);
+ mbuf = SvPV_const(mstr, len);
if ((msize = len - sizeof(long)) < 0)
Perl_croak(aTHX_ "Arg too short for msgsnd");
SETERRNO(0,0);
@@ -2147,7 +2149,6 @@ Perl_do_msgrcv(pTHX_ SV **mark, SV **sp)
char *mbuf;
long mtype;
I32 msize, flags, ret;
- STRLEN len;
const I32 id = SvIVx(*++mark);
(void)sp;
@@ -2158,7 +2159,7 @@ Perl_do_msgrcv(pTHX_ SV **mark, SV **sp)
msize = SvIVx(*++mark);
mtype = (long)SvIVx(*++mark);
flags = SvIVx(*++mark);
- SvPV_force(mstr, len);
+ SvPV_force_nolen(mstr);
mbuf = SvGROW(mstr, sizeof(long)+msize+1);
SETERRNO(0,0);
@@ -2182,13 +2183,13 @@ Perl_do_semop(pTHX_ SV **mark, SV **sp)
{
#ifdef HAS_SEM
SV *opstr;
- char *opbuf;
+ const char *opbuf;
STRLEN opsize;
const I32 id = SvIVx(*++mark);
(void)sp;
opstr = *++mark;
- opbuf = SvPV(opstr, opsize);
+ opbuf = SvPV_const(opstr, opsize);
if (opsize < 3 * SHORTSIZE
|| (opsize % (3 * SHORTSIZE))) {
SETERRNO(EINVAL,LIB_INVARG);
@@ -2237,7 +2238,6 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
SV *mstr;
char *shm;
I32 mpos, msize;
- STRLEN len;
struct shmid_ds shmds;
const I32 id = SvIVx(*++mark);
(void)sp;
@@ -2260,7 +2260,7 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
/* suppress warning when reading into undef var (tchrist 3/Mar/00) */
if (! SvOK(mstr))
sv_setpvn(mstr, "", 0);
- SvPV_force(mstr, len);
+ SvPV_force_nolen(mstr);
mbuf = SvGROW(mstr, msize+1);
Copy(shm + mpos, mbuf, msize, char);
@@ -2274,8 +2274,9 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
}
else {
I32 n;
+ STRLEN len;
- const char *mbuf = SvPV(mstr, len);
+ const char *mbuf = SvPV_const(mstr, len);
if ((n = len) > msize)
n = msize;
Copy(mbuf, shm + mpos, n, char);
@@ -2433,7 +2434,7 @@ Perl_start_glob (pTHX_ SV *tmpglob, IO *io)
#endif /* !CSH */
#endif /* !DOSISH */
#endif /* MACOS_TRADITIONAL */
- (void)do_open(PL_last_in_gv, SvPVX(tmpcmd), SvCUR(tmpcmd),
+ (void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd),
FALSE, O_RDONLY, 0, Nullfp);
fp = IoIFP(io);
#endif /* !VMS */
diff --git a/doop.c b/doop.c
index b17da1ad29..73ccdcdf96 100644
--- a/doop.c
+++ b/doop.c
@@ -395,8 +395,8 @@ S_do_trans_simple_utf8(pTHX_ SV *sv)
STATIC I32
S_do_trans_count_utf8(pTHX_ SV *sv)
{
- U8 *s;
- U8 *start = 0, *send;
+ const U8 *s;
+ const U8 *start = 0, *send;
I32 matches = 0;
STRLEN len;
@@ -407,7 +407,7 @@ S_do_trans_count_utf8(pTHX_ SV *sv)
const UV extra = none + 1;
U8 hibit = 0;
- s = (U8*)SvPV(sv, len);
+ s = (const U8*)SvPV_const(sv, len);
if (!SvUTF8(sv)) {
const U8 *t = s;
const U8 *e = s + len;
@@ -1071,7 +1071,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
}
else {
STRLEN rslen, rs_charlen;
- char *rsptr = SvPV(PL_rs, rslen);
+ const char *rsptr = SvPV_const(PL_rs, rslen);
rs_charlen = SvUTF8(PL_rs)
? sv_len_utf8(PL_rs)
@@ -1098,7 +1098,7 @@ Perl_do_chomp(pTHX_ register SV *sv)
* Do not recode PL_rs as a side-effect. */
svrecode = newSVpvn(rsptr, rslen);
sv_recode_to_utf8(svrecode, PL_encoding);
- rsptr = SvPV(svrecode, rslen);
+ rsptr = SvPV_const(svrecode, rslen);
rs_charlen = sv_len_utf8(svrecode);
}
else {
diff --git a/dump.c b/dump.c
index fed067df6d..ddeacf4da3 100644
--- a/dump.c
+++ b/dump.c
@@ -406,7 +406,7 @@ sequence(pTHX_ register const OP *o)
{
dVAR;
SV *op;
- char *key;
+ const char *key;
STRLEN len;
const OP *oldop = 0;
OP *l;
@@ -415,13 +415,13 @@ sequence(pTHX_ register const OP *o)
return;
op = newSVuv(PTR2UV(o));
- key = SvPV(op, len);
+ key = SvPV_const(op, len);
if (hv_exists(Sequence, key, len))
return;
for (; o; o = o->op_next) {
op = newSVuv(PTR2UV(o));
- key = SvPV(op, len);
+ key = SvPV_const(op, len);
if (hv_exists(Sequence, key, len))
break;
@@ -501,11 +501,11 @@ sequence_num(pTHX_ const OP *o)
dVAR;
SV *op,
**seq;
- char *key;
+ const char *key;
STRLEN len;
if (!o) return 0;
op = newSVuv(PTR2UV(o));
- key = SvPV(op, len);
+ key = SvPV_const(op, len);
seq = hv_fetch(Sequence, key, len, 0);
return seq ? SvUV(*seq): 0;
}
@@ -1452,7 +1452,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
U32 hash = HeHASH(he);
keysv = hv_iterkeysv(he);
- keypv = SvPV(keysv, len);
+ keypv = SvPV_const(keysv, len);
elt = hv_iterval(hv, he);
Perl_dump_indent(aTHX_ level+1, file, "Elt %s ", pv_display(d, keypv, len, 0, pvlim));
if (SvUTF8(keysv))
@@ -1467,7 +1467,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
break;
case SVt_PVCV:
if (SvPOK(sv))
- Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV_nolen(sv));
+ Perl_dump_indent(aTHX_ level, file, " PROTOTYPE = \"%s\"\n", SvPV_nolen_const(sv));
/* FALL THROUGH */
case SVt_PVFM:
do_hv_dump(level, file, " COMP_STASH", CvSTASH(sv));
@@ -1620,7 +1620,7 @@ Perl_debop(pTHX_ const OP *o)
if (cGVOPo_gv) {
SV *sv = NEWSV(0,0);
gv_fullname3(sv, cGVOPo_gv, Nullch);
- PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
+ PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv));
SvREFCNT_dec(sv);
}
else
@@ -1640,7 +1640,7 @@ Perl_debop(pTHX_ const OP *o)
} else
sv = Nullsv;
if (sv)
- PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen(sv));
+ PerlIO_printf(Perl_debug_log, "(%s)", SvPV_nolen_const(sv));
else
PerlIO_printf(Perl_debug_log, "[%"UVuf"]", (UV)o->op_targ);
}
diff --git a/op.c b/op.c
index 12a8c25f57..f165c25e0c 100644
--- a/op.c
+++ b/op.c
@@ -2491,7 +2491,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
t = uvuni_to_utf8_flags(tmpbuf, 0x7fffffff,
UNICODE_ALLOW_SUPER);
sv_catpvn(transv, (char*)tmpbuf, t - tmpbuf);
- t = (U8*)SvPVX(transv);
+ t = (const U8*)SvPVX_const(transv);
tlen = SvCUR(transv);
tend = t + tlen;
Safefree(cp);
@@ -5507,7 +5507,7 @@ Perl_ck_fun(pTHX_ OP *o)
}
if (tmpstr) {
- name = SvPV(tmpstr, len);
+ name = SvPV_const(tmpstr, len);
sv_2mortal(tmpstr);
}
}
@@ -6812,13 +6812,13 @@ Perl_peep(pTHX_ register OP *o)
fields = (GV**)hv_fetch(SvSTASH(lexname), "FIELDS", 6, FALSE);
if (!fields || !GvHV(*fields))
break;
- key = SvPV(*svp, keylen);
+ key = SvPV_const(*svp, keylen);
if (!hv_fetch(GvHV(*fields), key,
SvUTF8(*svp) ? -(I32)keylen : keylen, FALSE))
{
Perl_croak(aTHX_ "No such class field \"%s\" "
"in variable %s of type %s",
- key, SvPV_nolen(lexname), HvNAME_get(SvSTASH(lexname)));
+ key, SvPV_nolen_const(lexname), HvNAME_get(SvSTASH(lexname)));
}
break;
@@ -6829,7 +6829,7 @@ Perl_peep(pTHX_ register OP *o)
SV *lexname;
GV **fields;
SV **svp;
- char *key;
+ const char *key;
STRLEN keylen;
SVOP *first_key_op, *key_op;
@@ -6869,7 +6869,7 @@ Perl_peep(pTHX_ register OP *o)
if (key_op->op_type != OP_CONST)
continue;
svp = cSVOPx_svp(key_op);
- key = SvPV(*svp, keylen);
+ key = SvPV_const(*svp, keylen);
if (!hv_fetch(GvHV(*fields), key,
SvUTF8(*svp) ? -(I32)keylen : keylen, FALSE))
{
diff --git a/sv.c b/sv.c
index 6f93a3f84c..81f407c25c 100644
--- a/sv.c
+++ b/sv.c
@@ -765,7 +765,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ,
av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE));
sv = *av_fetch(av, targ, FALSE);
/* SvLEN in a pad name is not to be trusted */
- str = SvPV(sv,len);
+ str = SvPV_const(sv,len);
sv_setpvn(name, str, len);
}
@@ -1120,7 +1120,7 @@ Perl_report_uninit(pTHX_ SV* uninit_sv)
sv_insert(varname, 0, 0, " ", 1);
}
Perl_warner(aTHX_ packWARN(WARN_UNINITIALIZED), PL_warn_uninit,
- varname ? SvPV_nolen(varname) : "",
+ varname ? SvPV_nolen_const(varname) : "",
" in ", OP_DESC(PL_op));
}
else
@@ -2024,11 +2024,11 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen)
sv_unref(sv);
if (SvTYPE(sv) < SVt_PV) {
sv_upgrade(sv, SVt_PV);
- s = SvPVX(sv);
+ s = SvPVX_mutable(sv);
}
else if (SvOOK(sv)) { /* pv is offset? */
sv_backoff(sv);
- s = SvPVX(sv);
+ s = SvPVX_mutable(sv);
if (newlen > SvLEN(sv))
newlen += 10 * (newlen - SvCUR(sv)); /* avoid copy each time */
#ifdef HAS_64K_LIMIT
@@ -2043,7 +2043,7 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen)
newlen = PERL_STRLEN_ROUNDUP(newlen);
if (SvLEN(sv) && s) {
#ifdef MYMALLOC
- const STRLEN l = malloced_size((void*)SvPVX(sv));
+ const STRLEN l = malloced_size((void*)SvPVX_const(sv));
if (newlen <= l) {
SvLEN_set(sv, l);
return s;
@@ -3441,6 +3441,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags)
register const char *typestr;
if (SvAMAGIC(sv) && (tmpstr=AMG_CALLun(sv,string)) &&
(!SvROK(tmpstr) || (SvRV(tmpstr) != SvRV(sv)))) {
+ /* FIXME - figure out best way to pass context inwards. */
char *pv = lp ? SvPV(tmpstr, *lp) : SvPV_nolen(tmpstr);
if (SvUTF8(tmpstr))
SvUTF8_on(sv);
@@ -3916,9 +3917,9 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags)
* had a FLAG in SVs to signal if there are any hibit
* chars in the PV. Given that there isn't such a flag
* make the loop as fast as possible. */
- U8 *s = (U8 *) SvPVX(sv);
- U8 *e = (U8 *) SvEND(sv);
- U8 *t = s;
+ const U8 *s = (U8 *) SvPVX_const(sv);
+ const U8 *e = (U8 *) SvEND(sv);
+ const U8 *t = s;
int hibit = 0;
while (t < e) {
@@ -3928,11 +3929,11 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags)
}
if (hibit) {
STRLEN len = SvCUR(sv) + 1; /* Plus the \0 */
- s = bytes_to_utf8((U8*)s, &len);
+ char *recoded = bytes_to_utf8((U8*)s, &len);
SvPV_free(sv); /* No longer using what was there before. */
- SvPV_set(sv, (char*)s);
+ SvPV_set(sv, recoded);
SvCUR_set(sv, len - 1);
SvLEN_set(sv, len); /* No longer know the real size. */
}
@@ -4024,8 +4025,8 @@ bool
Perl_sv_utf8_decode(pTHX_ register SV *sv)
{
if (SvPOKp(sv)) {
- U8 *c;
- U8 *e;
+ const U8 *c;
+ const U8 *e;
/* The octets may have got themselves encoded - get them back as
* bytes
@@ -4036,10 +4037,10 @@ Perl_sv_utf8_decode(pTHX_ register SV *sv)
/* it is actually just a matter of turning the utf8 flag on, but
* we want to make sure everything inside is valid utf8 first.
*/
- c = (U8 *) SvPVX(sv);
+ c = (const U8 *) SvPVX_const(sv);
if (!is_utf8_string(c, SvCUR(sv)+1))
return FALSE;
- e = (U8 *) SvEND(sv);
+ e = (const U8 *) SvEND(sv);
while (c < e) {
U8 ch = *c++;
if (!UTF8_IS_INVARIANT(ch)) {
@@ -4373,7 +4374,8 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, register SV *sstr, I32 flags)
}
if (!intro)
cv_ckproto(cv, (GV*)dstr,
- SvPOK(sref) ? SvPVX(sref) : Nullch);
+ SvPOK(sref)
+ ? SvPVX_const(sref) : Nullch);
}
GvCV(dstr) = (CV*)sref;
GvCVGEN(dstr) = 0; /* Switch off cacheness. */
@@ -5180,7 +5182,7 @@ Perl_sv_catsv_flags(pTHX_ SV *dsv, register SV *ssv, I32 flags)
SV* csv = sv_2mortal(newSVpvn(spv, slen));
sv_utf8_upgrade(csv);
- spv = SvPV(csv, slen);
+ spv = SvPV_const(csv, slen);
}
else
sv_utf8_upgrade_nomg(dsv);
@@ -5690,7 +5692,7 @@ Perl_sv_insert(pTHX_ SV *bigstr, STRLEN offset, STRLEN len, const char *little,
(void)SvPOK_only_UTF8(bigstr);
if (offset + len > curlen) {
SvGROW(bigstr, offset+len+1);
- Zero(SvPVX_const(bigstr)+curlen, offset+len-curlen, char);
+ Zero(SvPVX(bigstr)+curlen, offset+len-curlen, char);
SvCUR_set(bigstr, offset+len);
}
@@ -5967,7 +5969,7 @@ Perl_sv_clear(pTHX_ register SV *sv)
freescalar:
/* Don't bother with SvOOK_off(sv); as we're only going to free it. */
if (SvOOK(sv)) {
- SvPV_set(sv, SvPVX(sv) - SvIVX(sv));
+ SvPV_set(sv, SvPVX_mutable(sv) - SvIVX(sv));
/* Don't even bother with turning off the OOK flag. */
}
/* FALL THROUGH */
@@ -6631,12 +6633,12 @@ Perl_sv_eq(pTHX_ register SV *sv1, register SV *sv2)
if (SvUTF8(sv1)) {
svrecode = newSVpvn(pv2, cur2);
sv_recode_to_utf8(svrecode, PL_encoding);
- pv2 = SvPV(svrecode, cur2);
+ pv2 = SvPV_const(svrecode, cur2);
}
else {
svrecode = newSVpvn(pv1, cur1);
sv_recode_to_utf8(svrecode, PL_encoding);
- pv1 = SvPV(svrecode, cur1);
+ pv1 = SvPV_const(svrecode, cur1);
}
/* Now both are in UTF-8. */
if (cur1 != cur2) {
@@ -6724,7 +6726,7 @@ Perl_sv_cmp(pTHX_ register SV *sv1, register SV *sv2)
if (PL_encoding) {
svrecode = newSVpvn(pv2, cur2);
sv_recode_to_utf8(svrecode, PL_encoding);
- pv2 = SvPV(svrecode, cur2);
+ pv2 = SvPV_const(svrecode, cur2);
}
else {
pv2 = tpv = (char*)bytes_to_utf8((const U8*)pv2, &cur2);
@@ -6734,7 +6736,7 @@ Perl_sv_cmp(pTHX_ register SV *sv1, register SV *sv2)
if (PL_encoding) {
svrecode = newSVpvn(pv1, cur1);
sv_recode_to_utf8(svrecode, PL_encoding);
- pv1 = SvPV(svrecode, cur1);
+ pv1 = SvPV_const(svrecode, cur1);
}
else {
pv1 = tpv = (char*)bytes_to_utf8((const U8*)pv1, &cur1);
@@ -6848,12 +6850,13 @@ Perl_sv_collxfrm(pTHX_ SV *sv, STRLEN *nxp)
mg = SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_collxfrm) : (MAGIC *) NULL;
if (!mg || !mg->mg_ptr || *(U32*)mg->mg_ptr != PL_collation_ix) {
- char *s, *xf;
+ const char *s;
+ char *xf;
STRLEN len, xlen;
if (mg)
Safefree(mg->mg_ptr);
- s = SvPV(sv, len);
+ s = SvPV_const(sv, len);
if ((xf = mem_collxfrm(s, len, &xlen))) {
if (SvREADONLY(sv)) {
SAVEFREEPV(xf);
@@ -7001,7 +7004,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append)
Perl_croak(aTHX_ "Wide character in $/");
}
}
- rsptr = SvPV(PL_rs, rslen);
+ rsptr = SvPV_const(PL_rs, rslen);
}
}
@@ -8214,12 +8217,10 @@ Perl_sv_nv(pTHX_ register SV *sv)
char *
Perl_sv_pv(pTHX_ SV *sv)
{
- STRLEN n_a;
-
if (SvPOK(sv))
return SvPVX(sv);
- return sv_2pv(sv, &n_a);
+ return sv_2pv(sv, 0);
}
/*
@@ -10119,7 +10120,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
else {
SV *nsv = sv_2mortal(newSVpvn(eptr, elen));
sv_utf8_upgrade(nsv);
- eptr = SvPVX(nsv);
+ eptr = SvPVX_const(nsv);
elen = SvCUR(nsv);
}
SvGROW(sv, SvCUR(sv) + elen + 1);
@@ -12476,7 +12477,7 @@ Perl_sv_recode_to_utf8(pTHX_ SV *sv, SV *encoding)
if (SvPOK(sv) && !SvUTF8(sv) && !IN_BYTES && SvROK(encoding)) {
SV *uni;
STRLEN len;
- char *s;
+ const char *s;
dSP;
ENTER;
SAVETMPS;
@@ -12500,12 +12501,11 @@ Perl_sv_recode_to_utf8(pTHX_ SV *sv, SV *encoding)
SPAGAIN;
uni = POPs;
PUTBACK;
- s = SvPV(uni, len);
+ s = SvPV_const(uni, len);
if (s != SvPVX_const(sv)) {
SvGROW(sv, len + 1);
- Move(s, SvPVX_const(sv), len, char);
+ Move(s, SvPVX(sv), len + 1, char);
SvCUR_set(sv, len);
- SvPVX(sv)[len] = 0;
}
FREETMPS;
LEAVE;