Skip to content

Commit ba2f996

Browse files
committed
StreamCopy avoid memory leak
1 parent b36fb34 commit ba2f996

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/AudioTools/CoreAudio/StreamCopy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ class StreamCopyT {
5555

5656
/// Ends the processing
5757
void end() {
58+
if (is_cleanup_from) delete this->from;
5859
this->from = nullptr;
5960
this->to = nullptr;
6061
}
6162

6263
/// assign a new output and input stream
6364
void begin(Print &to, Stream &from){
65+
is_cleanup_from = true;
6466
this->from = new AudioStreamWrapper(from);
6567
this->to = &to;
6668
begin();
@@ -357,6 +359,7 @@ class StreamCopyT {
357359
int (*availableCallback)(Stream*stream)=nullptr;
358360
void *onWriteObj = nullptr;
359361
bool is_first = false;
362+
bool is_cleanup_from = false;
360363
bool check_available_for_write = false;
361364
bool check_available = true;
362365
const char* actual_mime = nullptr;

0 commit comments

Comments
 (0)