From c65819d3eb5ac202b768ae6dcbd36539646afb46 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 13:42:20 -0500 Subject: [PATCH] xo-arena: memory checks in DArenaVector::push_back() --- include/xo/arena/DArenaVector.hpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/include/xo/arena/DArenaVector.hpp b/include/xo/arena/DArenaVector.hpp index a5834ea..f8bd982 100644 --- a/include/xo/arena/DArenaVector.hpp +++ b/include/xo/arena/DArenaVector.hpp @@ -296,25 +296,27 @@ namespace xo { size_type z = size_ + 1; size_type req_z = z * sizeof(T); - this->store_.expand(req_z); + if (this->store_.expand(req_z)) { + T * addr = this->_address_of(size_); - T * addr = this->_address_of(size_); + new (addr) T{std::move(x)}; - new (addr) T{std::move(x)}; - - this->size_ = z; + this->size_ = z; + } } template void DArenaVector::push_back(const T & x) { size_type z = size_ + 1; - store_.expand(z * sizeof(T)); - T * addr = this->_address_of(size_); - new (addr) T{x}; + if (this->store_.expand(z * sizeof(T))) { + T * addr = this->_address_of(size_); - size_ = z; + new (addr) T{x}; + + this->size_ = z; + } } template