From 6db3c59206befc7a75c6682e6caed4854d4e6fbb Mon Sep 17 00:00:00 2001 From: alexanderMathew Date: Sat, 21 Sep 2024 19:22:48 -0700 Subject: [PATCH] add check for capacity size before allocating memory --- native/src/seal/dynarray.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/native/src/seal/dynarray.h b/native/src/seal/dynarray.h index 1d2815e14..39544515b 100644 --- a/native/src/seal/dynarray.h +++ b/native/src/seal/dynarray.h @@ -424,6 +424,11 @@ namespace seal */ inline void reserve(std::size_t capacity) { + + // Check if capacity is greater than capacity_ before allocating memory + if (capacity <= capacity_) { + return; + } std::size_t copy_size = std::min<>(capacity, size_); // Create new allocation and copy over value