X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdata%2Fsegment.cpp;h=bc08fd07917564d86e13f35f3d37ad20dcae64e9;hp=111b62b71aadf0c43189540050c55e92de29dc43;hb=e7216ae0a66fe1563514cbd3f67f2e240d010315;hpb=ff4bf6bd8141b9e7518b7bf431e45beff671e764 diff --git a/pv/data/segment.cpp b/pv/data/segment.cpp index 111b62b7..bc08fd07 100644 --- a/pv/data/segment.cpp +++ b/pv/data/segment.cpp @@ -78,8 +78,9 @@ void Segment::set_capacity(const uint64_t new_capacity) assert(capacity_ >= sample_count_); if (new_capacity > capacity_) { - capacity_ = new_capacity; + // If we're out of memory, this will throw std::bad_alloc data_.resize((new_capacity * unit_size_) + sizeof(uint64_t)); + capacity_ = new_capacity; } }