diff options
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1514,10 +1514,11 @@ rb_ary_sort_bang(VALUE ary) ruby_qsort(RARRAY_PTR(tmp), RARRAY_LEN(tmp), sizeof(VALUE), rb_block_given_p()?sort_1:sort_2, &RBASIC(tmp)->klass); if (RARRAY(ary)->ptr != RARRAY(tmp)->ptr) { - xfree(RARRAY(ary)->ptr); + if (!ARY_SHARED_P(ary)) xfree(RARRAY(ary)->ptr); RARRAY(ary)->ptr = RARRAY(tmp)->ptr; RARRAY(ary)->len = RARRAY(tmp)->len; RARRAY(ary)->aux.capa = RARRAY(tmp)->aux.capa; + FL_SET(ary, ELTS_SHARED); }; FL_UNSET(ary, ELTS_SHARED); RARRAY(tmp)->ptr = 0; |