Actions
Bug #13053
closedArray#select! can resize to negative size
Description
Since Ruby 2.3 ([Feature #10714]), the following code cause the Array to be nagative number size.
ary = [1,2,3,4,5]
ary.select! { |i| ary.clear if i==5; false }
p ary #=> []
p ary.size #=> -5
Updated by Anonymous about 8 years ago
- Status changed from Open to Closed
Applied in changeset r57121.
array.c: do not resize to less than 0
Shrinking the Array from the block invoked by Array#select! or
Array#reject! causes the Array to be a negative number size. Ensure that
the resulting Array won't be smaller than 0.
[ruby-core:78739] [Bug #13053]
Updated by nagachika (Tomoyuki Chikanaga) almost 8 years ago
- Backport changed from 2.1: DONTNEED, 2.2: DONTNEED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONTNEED, 2.3: DONE
ruby_2_3 r58149 merged revision(s) 57121.
Actions
Like0
Like0Like0