From 94fa180c07049483a57f24dbe2b8dab27f8909df Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 25 Sep 2006 22:58:13 +0000 Subject: [PATCH] * array.c (rb_ary_shift): should not move memory region if array body is shared. a patch from Kent Sibilev . [ruby-core:08922] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dd29cf1761..4e0f1663eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Sep 26 07:55:16 2006 Yukihiro Matsumoto + + * array.c (rb_ary_shift): should not move memory region if array + body is shared. a patch from Kent Sibilev . + [ruby-core:08922] + Mon Sep 25 23:10:46 2006 Yukihiro Matsumoto * dir.c (rb_push_glob): need not to check by FilePathValue(). diff --git a/array.c b/array.c index 73f55504a8..4896ed24fb 100644 --- a/array.c +++ b/array.c @@ -578,7 +578,7 @@ rb_ary_shift(VALUE ary) rb_ary_modify_check(ary); if (RARRAY_LEN(ary) == 0) return Qnil; top = RARRAY_PTR(ary)[0]; - if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) { + if (RARRAY_LEN(ary) < ARY_DEFAULT_SIZE && !FL_TEST(ary, ELTS_SHARED)) { MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+1, VALUE, RARRAY_LEN(ary)); ARY_SET_LEN(ary, RARRAY_LEN(ary)-1); }