Skip to content

Commit

Permalink
Merge pull request #1269 from iskunk/vg-fix-14
Browse files Browse the repository at this point in the history
Fix for Valgrind-reported leaked file handle
  • Loading branch information
vlazzarini committed Apr 24, 2021
2 parents 69e7d01 + b3e0540 commit 8ac6301
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion interfaces/csPerfThread.cpp
Expand Up @@ -221,6 +221,13 @@ class CsPerfThreadMsg_Record: public CsoundPerformanceThreadMessage {
return 0;
}
~CsPerfThreadMsg_Record() {
CsoundPerformanceThreadMessage::lockRecord();
recordData_t *recordData = CsoundPerformanceThreadMessage::getRecordData();
if (recordData->sfile) {
sf_close((SNDFILE *) recordData->sfile);
recordData->sfile = NULL;
}
CsoundPerformanceThreadMessage::unlockRecord();
}
private:
std::string filename;
Expand All @@ -239,7 +246,10 @@ class CsPerfThreadMsg_StopRecord: public CsoundPerformanceThreadMessage {
if (recordData->running) {
recordData->running = false;
csoundJoinThread(recordData->thread);
sf_close((SNDFILE *) recordData->sfile);
if (recordData->sfile) {
sf_close((SNDFILE *) recordData->sfile);
recordData->sfile = NULL;
}
}

CsoundPerformanceThreadMessage::unlockRecord();
Expand Down

0 comments on commit 8ac6301

Please sign in to comment.