Skip to content

Commit

Permalink
StreamCopy avoid memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Dec 8, 2024
1 parent b36fb34 commit ba2f996
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AudioTools/CoreAudio/StreamCopy.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ class StreamCopyT {

/// Ends the processing
void end() {
if (is_cleanup_from) delete this->from;
this->from = nullptr;
this->to = nullptr;
}

/// assign a new output and input stream
void begin(Print &to, Stream &from){
is_cleanup_from = true;
this->from = new AudioStreamWrapper(from);
this->to = &to;
begin();
Expand Down Expand Up @@ -357,6 +359,7 @@ class StreamCopyT {
int (*availableCallback)(Stream*stream)=nullptr;
void *onWriteObj = nullptr;
bool is_first = false;
bool is_cleanup_from = false;
bool check_available_for_write = false;
bool check_available = true;
const char* actual_mime = nullptr;
Expand Down

0 comments on commit ba2f996

Please sign in to comment.