summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/array.c b/array.c
index 5aefe9f8c0..45eef76c1f 100644
--- a/array.c
+++ b/array.c
@@ -1758,10 +1758,12 @@ rb_ary_sort_bang(VALUE ary)
}
else {
assert(!ARY_EMBED_P(tmp));
- if (ARY_EMBED_P(ary)) FL_UNSET_EMBED(ary);
- if (RARRAY_PTR(ary) != RARRAY_PTR(tmp)) {
+ if (ARY_EMBED_P(ary) || RARRAY_PTR(ary) != RARRAY_PTR(tmp)) {
assert(!ARY_SHARED_P(tmp));
- if (ARY_SHARED_P(ary)) {
+ if (ARY_EMBED_P(ary)) {
+ FL_UNSET_EMBED(ary);
+ }
+ else if (ARY_SHARED_P(ary)) {
rb_ary_unshare(ary);
}
else {