Skip to content

Commit 47c6588

Browse files
committed
Sound: fix typo and mem leaks
1 parent b0d0c74 commit 47c6588

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/detection/sound/sound_obsd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const char* ffDetectSound(FFlist* devices)
6464
return "sioctl_ondesc() failed";
6565

6666
if (bundle.iLevel != bundle.iMute || bundle.iLevel == 0)
67-
return "Unexpecd sioctl_ondesc() result";
67+
return "Unexpected sioctl_ondesc() result";
6868

6969
FFSoundDevice* device = ffListAdd(devices);
7070
ffStrbufInitS(&device->name, bundle.name);

src/detection/sound/sound_windows.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ extern "C" {
99
#include <endpointvolume.h>
1010
#include <functiondiscoverykeys_devpkey.h>
1111

12+
static void ffCoTaskMemFreeWrapper(void* pptr)
13+
{
14+
assert(pptr != NULL);
15+
void* ptr = *(void**)pptr;
16+
if (ptr) CoTaskMemFree(ptr);
17+
}
18+
#define FF_COTASK_AUTO_FREE __attribute__((__cleanup__(ffCoTaskMemFreeWrapper)))
19+
1220
const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
1321
{
1422
const char* error = ffInitCom();
@@ -20,7 +28,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
2028
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&pEnum)))
2129
return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed";
2230

23-
LPWSTR mainDeviceId = NULL;
31+
LPWSTR FF_COTASK_AUTO_FREE mainDeviceId = NULL;
2432

2533
{
2634
IMMDevice* FF_AUTO_RELEASE_COM_OBJECT pDefaultDevice = NULL;
@@ -47,7 +55,7 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
4755
if (FAILED(pDevices->Item(deviceIdx, &immDevice)))
4856
continue;
4957

50-
LPWSTR immDeviceId = NULL;
58+
LPWSTR FF_COTASK_AUTO_FREE immDeviceId = NULL;
5159
if (FAILED(immDevice->GetId(&immDeviceId)))
5260
continue;
5361

0 commit comments

Comments
 (0)