summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2019-02-04 22:09:31 -0700
committerKarl Williamson <khw@cpan.org>2019-02-05 09:31:45 -0700
commite2e3bb6ab2dc831e06e3f552bfafd7c66ad52179 (patch)
tree595b4ae7413f656c7545d90ae5487593bb55e2d2 /sv.c
parentf9908fb6a0a784094ae5b2ec59d55803334ef798 (diff)
downloadperl-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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sv.c b/sv.c
index b3c402441a..0a4a2e531a 100644
--- a/sv.c
+++ b/sv.c
@@ -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