diff options
author | Karl Williamson <khw@cpan.org> | 2019-02-04 22:09:31 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2019-02-05 09:31:45 -0700 |
commit | e2e3bb6ab2dc831e06e3f552bfafd7c66ad52179 (patch) | |
tree | 595b4ae7413f656c7545d90ae5487593bb55e2d2 /sv.c | |
parent | f9908fb6a0a784094ae5b2ec59d55803334ef798 (diff) | |
download | perl-e2e3bb6ab2dc831e06e3f552bfafd7c66ad52179.tar.gz |
sv_utf8_upgrade_flags_grow(): Alloc extra byte if empty
People may call this expecting that the 'extra' parameter is on top of
whatever is in there. If something is in there, that already includes a
NUL, but if nothing is in there, for safety, add a byte to the request.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -3518,7 +3518,8 @@ Perl_sv_utf8_upgrade_flags_grow(pTHX_ SV *const sv, const I32 flags, STRLEN extr } if (SvCUR(sv) == 0) { - if (extra) SvGROW(sv, extra); + if (extra) SvGROW(sv, extra + 1); /* Make sure is room for a trailing + byte */ } else { /* Assume Latin-1/EBCDIC */ /* This function could be much more efficient if we * had a FLAG in SVs to signal if there are any variant |