diff options
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -2069,7 +2069,7 @@ static void str_make_independent_expand(VALUE str, long len, long expand, const int termlen) { char *ptr; - const char *oldptr; + char *oldptr; long capa = len + expand; if (len > capa) len = capa; @@ -2088,6 +2088,9 @@ str_make_independent_expand(VALUE str, long len, long expand, const int termlen) if (oldptr) { memcpy(ptr, oldptr, len); } + if (FL_TEST_RAW(str, STR_NOEMBED|STR_NOFREE|STR_SHARED) == STR_NOEMBED) { + xfree(oldptr); + } STR_SET_NOEMBED(str); FL_UNSET(str, STR_SHARED|STR_NOFREE); TERM_FILL(ptr + len, termlen); |