(void)utf8_to_uv((U8*)s, &len);
if (len == 1) {
/* illegal UTF8, make it valid */
- /* need to grow with 1 char to be safe */
char *old_pvx = SvPVX(sv);
- d = SvGROW(sv, SvCUR(sv)+2) + (d - old_pvx);
+ /* need space for two characters and a null */
+ d = SvGROW(sv, SvCUR(sv) + 2 + 1) + (d - old_pvx);
d = (char*)uv_to_utf8((U8*)d, (U8)*s++);
}
else {