From 5971d3d3b3566e793a8f8f4de19d823860c252c6 Mon Sep 17 00:00:00 2001 From: Maxime Biette Date: Sun, 11 Jul 2021 18:33:41 -0400 Subject: [PATCH 1/2] Fix destructor crash due to wild pointer Otherwise when RingBuffer is deleted before its init() being called it would crash in the destructor due to its _buffer pointer not being initialized. --- core/src/dsp/buffer.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/dsp/buffer.h b/core/src/dsp/buffer.h index 8c199ce2..6a0943ba 100644 --- a/core/src/dsp/buffer.h +++ b/core/src/dsp/buffer.h @@ -8,7 +8,9 @@ namespace dsp { template class RingBuffer { public: - RingBuffer() { + RingBuffer(): + _buffer{nullptr} + { } From 4aaf71f5ccdd6f8bad0aa1725689c01e7d5ff66c Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Mon, 12 Jul 2021 00:58:39 +0200 Subject: [PATCH 2/2] Fixed code style --- core/src/dsp/buffer.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/core/src/dsp/buffer.h b/core/src/dsp/buffer.h index 6a0943ba..a43c48e8 100644 --- a/core/src/dsp/buffer.h +++ b/core/src/dsp/buffer.h @@ -8,11 +8,7 @@ namespace dsp { template class RingBuffer { public: - RingBuffer(): - _buffer{nullptr} - { - - } + RingBuffer() {} RingBuffer(int maxLatency) { init(maxLatency); } @@ -202,7 +198,7 @@ namespace dsp { } private: - T* _buffer; + T* _buffer = NULL; int size; int readc; int writec; @@ -333,4 +329,4 @@ namespace dsp { bool stopWorker = false; }; -}; \ No newline at end of file +};