mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-31 10:02:49 +01:00
Sound: always initialize identifier and destroy it to avoid memleaks
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
typedef struct FFSoundDevice
|
||||
{
|
||||
FFstrbuf identifier; // Used internally, not guaranteed to be initialized
|
||||
FFstrbuf identifier;
|
||||
FFstrbuf name;
|
||||
FFstrbuf manufacturer;
|
||||
uint8_t volume; // 0-100%
|
||||
|
||||
@@ -40,6 +40,7 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FFlist* de
|
||||
device->main = deviceId == mainDeviceId;
|
||||
device->active = device->main;
|
||||
device->volume = 0;
|
||||
ffStrbufInitF(&device->identifier, "%u", (unsigned) deviceId);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->manufacturer);
|
||||
|
||||
|
||||
@@ -63,9 +63,12 @@ const char* ffDetectSound(FF_MAYBE_UNUSED const FFinstance* instance, FF_MAYBE_U
|
||||
device->main = wcscmp(mainDeviceId, immDeviceId) == 0;
|
||||
device->active = !!(immState & DEVICE_STATE_ACTIVE);
|
||||
device->volume = 0;
|
||||
ffStrbufInit(&device->identifier);
|
||||
ffStrbufInit(&device->name);
|
||||
ffStrbufInit(&device->manufacturer);
|
||||
|
||||
ffStrbufSetWS(&device->identifier, immDeviceId);
|
||||
|
||||
{
|
||||
PROPVARIANT __attribute__((__cleanup__(PropVariantClear))) friendlyName;
|
||||
PropVariantInit(&friendlyName);
|
||||
|
||||
Reference in New Issue
Block a user