diff --git a/ChangeLog b/ChangeLog index 92b2edc31a..28a684539a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Tue Jun 21 16:13:45 2016 NARUSE, Yui + + * string.c (rb_str_casemap): fix memory leak. + Tue Jun 21 16:12:21 2016 NARUSE, Yui * string.c (rb_str_casemap): int is too small for string size. diff --git a/string.c b/string.c index 93d247f57e..a62ae2dd8d 100644 --- a/string.c +++ b/string.c @@ -5809,8 +5809,10 @@ rb_str_casemap(VALUE source, OnigCaseFoldType *flags, rb_encoding *enc) } /* fprintf(stderr, "Buffer count is %d\n", buffer_count); *//* for tuning */ - if (buffer_count==1) + if (buffer_count==1) { target = rb_str_new_with_class(source, (const char*)current_buffer->space, target_length); + xfree(current_buffer); + } else { char *target_current = RSTRING_PTR(target = rb_str_new_with_class(source, 0, target_length)); mapping_buffer *previous_buffer;