Thinko in #7222.
[p5sagit/p5-mst-13.2.git] / toke.c
diff --git a/toke.c b/toke.c
index e75d878..4b65d62 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -357,7 +357,6 @@ Perl_lex_start(pTHX_ SV *line)
            SAVEVPTR(PL_nextval[toke]);
        }
        SAVEI32(PL_nexttoke);
-       PL_nexttoke = 0;
     }
     SAVECOPLINE(PL_curcop);
     SAVEPPTR(PL_bufptr);
@@ -391,6 +390,7 @@ Perl_lex_start(pTHX_ SV *line)
     PL_lex_stuff = Nullsv;
     PL_lex_repl = Nullsv;
     PL_lex_inpat = 0;
+    PL_nexttoke = 0;
     PL_lex_inwhat = 0;
     PL_sublex_info.sub_inwhat = 0;
     PL_linestr = line;
@@ -812,7 +812,7 @@ Perl_str_to_version(pTHX_ SV *sv)
        I32 skip;
        UV n;
        if (utf)
-           n = utf8_to_uv((U8*)start, &skip, 0);
+           n = utf8_to_uv_chk((U8*)start, &skip, 0);
        else {
            n = *(U8*)start;
            skip = 1;
@@ -1323,7 +1323,7 @@ S_scan_const(pTHX_ char *start)
        /* (now in tr/// code again) */
 
        if (*s & 0x80 && thisutf) {
-          (void)utf8_to_uv((U8*)s, &len, 0);
+          (void)utf8_to_uv_chk((U8*)s, &len, 0);
           if (len == 1) {
               /* illegal UTF8, make it valid */
               char *old_pvx = SvPVX(sv);
@@ -1489,7 +1489,10 @@ S_scan_const(pTHX_ char *start)
                        char *ostart = SvPVX(sv);
                        SvCUR_set(sv, d - ostart);
                        SvPOK_on(sv);
+                       *d = '\0';
                        sv_utf8_upgrade(sv);
+                       /* this just broke our allocation above... */
+                       SvGROW(sv, send - start);
                        d = SvPVX(sv) + SvCUR(sv);
                        has_utf = TRUE;
                    }