summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-17 21:39:14 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-17 21:39:14 +0000
commitddffaf5208b679e4b54bc6391eafece54392c1c3 (patch)
tree498c46237a27411e203ec0b919a853f71232c340 /array.c
parent01b6b58998a97b4c4b0b27eef0be1a6d2adcecf6 (diff)
merge revision(s) 66756: [Backport #15479]
Mark array as "going to be modified" in `Array#reject!` Before this patch, if `reject!` is called on a shared array it can mutate the shared array rather than a copy. This patch marks the array as "going to be modified" so that the shared source array isn't mutated. [Bug #15479] [ruby-core:90781] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@66847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/array.c b/array.c
index 5fef843455..7b92bfe5b1 100644
--- a/array.c
+++ b/array.c
@@ -3540,6 +3540,7 @@ static VALUE
rb_ary_reject_bang(VALUE ary)
{
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
+ rb_ary_modify(ary);
return ary_reject_bang(ary);
}