Opened 2 years ago

Closed 2 years ago

#956 closed defect (fixed)

Vector::resize(0) crash

Reported by: Peter Owned by: Peter
Priority: major Milestone: yat 0.17.2
Component: utility Version: 0.17
Keywords: Cc:

Description

Vector::resize(0) crash if called on a zero-sized Vector.

The problem is that if both size() and n are 0 in the ::resize

if (size() == n) {
  all(init_value);
  return;
}
...

and calling all(double) when size is zero is bad. The obvious fix should be to check for zero size.

Change History (2)

comment:1 Changed 2 years ago by Peter

Owner: changed from Jari Häkkinen to Peter
Status: newaccepted

comment:2 Changed 2 years ago by Peter

Resolution: fixed
Status: acceptedclosed

In 3971:

fixes #956. Vector::resize(0) did not work when the vector was
zero-sized because ::resize calls ::all(double) which was not
implemented for zero-sized vectors. This fixes that.

Note: See TracTickets for help on using tickets.