Project

General

Profile

Actions

Bug #13053

closed

Array#select! can resize to negative size

Added by rhenium (Kazuki Yamaguchi) over 7 years ago. Updated about 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:78739]

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
Actions #1

Updated by Anonymous over 7 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) about 7 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

Also available in: Atom PDF

Like0
Like0Like0