diff options
author | Brian Fraser <fraserbn@gmail.com> | 2013-08-29 11:26:58 -0300 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-09-10 08:36:12 -0700 |
commit | 8405109152b060e3419c0cddc875535421bcc7ca (patch) | |
tree | 8281627e377acb8ae13c8253bacb5a3b6a59cc99 /toke.c | |
parent | cd313eb4878cb9858789ba98728a51205e8c78a9 (diff) | |
download | perl-8405109152b060e3419c0cddc875535421bcc7ca.tar.gz |
toke.c: "Unrecognized character" error shouldn't leak memory or mangle characters.
This error could've leaked memory if used within as eval, and could
cut off in the middle of a character, leaving worthless binary data
in the error message.
Diffstat (limited to 'toke.c')
-rw-r--r-- | toke.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -5159,22 +5159,20 @@ Perl_yylex(pTHX) goto keylookup; { SV *dsv = newSVpvs_flags("", SVs_TEMP); - const char *c = UTF ? savepv(sv_uni_display(dsv, newSVpvn_flags(s, + const char *c = UTF ? sv_uni_display(dsv, newSVpvn_flags(s, UTF8SKIP(s), SVs_TEMP | SVf_UTF8), - 10, UNI_DISPLAY_ISPRINT)) + 10, UNI_DISPLAY_ISPRINT) : Perl_form(aTHX_ "\\x%02X", (unsigned char)*s); len = UTF ? Perl_utf8_length(aTHX_ (U8 *) PL_linestart, (U8 *) s) : (STRLEN) (s - PL_linestart); if (len > UNRECOGNIZED_PRECEDE_COUNT) { d = UTF ? (char *) Perl_utf8_hop(aTHX_ (U8 *) s, -UNRECOGNIZED_PRECEDE_COUNT) : s - UNRECOGNIZED_PRECEDE_COUNT; } else { d = PL_linestart; - } - *s = '\0'; - sv_setpv(dsv, d); - if (UTF) - SvUTF8_on(dsv); - Perl_croak(aTHX_ "Unrecognized character %s; marked by <-- HERE after %"SVf"<-- HERE near column %d", c, SVfARG(dsv), (int) len + 1); + } + Perl_croak(aTHX_ "Unrecognized character %s; marked by <-- HERE after %"UTF8f"<-- HERE near column %d", c, + UTF8fARG(UTF, (s - d), d), + (int) len + 1); } case 4: case 26: |