summaryrefslogtreecommitdiffstats
path: root/include/jau/ringbuffer.hpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-01-18 16:47:21 +0100
committerSven Gothel <[email protected]>2021-01-18 16:47:21 +0100
commit1ba932716f2d382af56bf8ea69a57666e2c835d6 (patch)
tree8178585ba2d259670548aae381efc6d58e5e9343 /include/jau/ringbuffer.hpp
parent5a63705ab082b56119788e1dc6b6ddec5705e6a2 (diff)
ringbuffer: Fix cloneFrom(), resetImpl(); Validate dtor array nullptr (ABORT)
- cloneFrom(): Used wrong arguments to freeArray - resetImpl(): For public reset(..): arrays wasn't freed when resizing
Diffstat (limited to 'include/jau/ringbuffer.hpp')
-rw-r--r--include/jau/ringbuffer.hpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/jau/ringbuffer.hpp b/include/jau/ringbuffer.hpp
index f9ade91..2b7a7ba 100644
--- a/include/jau/ringbuffer.hpp
+++ b/include/jau/ringbuffer.hpp
@@ -116,7 +116,7 @@ template <typename T, std::nullptr_t nullelem, typename Size_type> class ringbuf
if( allocArrayAndCapacity ) {
capacityPlusOne = source.capacityPlusOne;
if( nullptr != array ) {
- freeArray(array, true);
+ freeArray(array);
}
array = newArray(capacityPlusOne);
} else if( capacityPlusOne != source.capacityPlusOne ) {
@@ -161,6 +161,9 @@ template <typename T, std::nullptr_t nullelem, typename Size_type> class ringbuf
if( nullptr != copyFrom && 0 < copyFromCount ) {
if( copyFromCount > capacityPlusOne-1 ) {
// new blank resized array
+ if( nullptr != array ) {
+ freeArray(array);
+ }
capacityPlusOne = copyFromCount + 1;
array = newArray(capacityPlusOne);
readPos = 0;
@@ -408,6 +411,9 @@ template <typename T, std::nullptr_t nullelem, typename Size_type> class ringbuf
{ }
~ringbuffer() noexcept {
+ if( nullptr == array ) {
+ ABORT("ringbuffer::dtor array==nullptr");
+ }
freeArray(array);
}