Skip to content

Commit

Permalink
fixed unbalanced CoInitialize/CoUninitialize call
Browse files Browse the repository at this point in the history
  • Loading branch information
Roland Aigner committed Sep 30, 2024
1 parent af3b361 commit 3e1669b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/asiolist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@ AsioDriverList::AsioDriverList ()
pdl = pdl->next;
}

if (numdrv) CoInitialize(0); // initialize COM
coInitialized_ = false;
if (numdrv) {
HRESULT hr = CoInitialize(0); // initialize COM
if( !FAILED( hr ) ) coInitialized_ = true;
}
}

AsioDriverList::~AsioDriverList ()
{
if (numdrv) {
deleteDrvStruct(lpdrvlist);
CoUninitialize();
if( coInitialized_ ) CoUninitialize(); // balanced call.
}
}

Expand Down
3 changes: 3 additions & 0 deletions include/asiolist.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ class AsioDriverList {
// or use directly access
LPASIODRVSTRUCT lpdrvlist;
int numdrv;

private:
bool coInitialized_;
};

typedef class AsioDriverList *LPASIODRIVERLIST;
Expand Down

0 comments on commit 3e1669b

Please sign in to comment.