From dbcd5b922ac3138070684f75ab4b69763c99b0be Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 13 Jan 2025 15:39:16 +0800 Subject: [PATCH] Sound: fix a memleak --- src/detection/sound/sound_linux.c | 2 +- src/modules/sound/sound.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/detection/sound/sound_linux.c b/src/detection/sound/sound_linux.c index bd309aca0..8fc371d12 100644 --- a/src/detection/sound/sound_linux.c +++ b/src/detection/sound/sound_linux.c @@ -13,7 +13,7 @@ static void paSinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, vo FFSoundDevice* device = ffListAdd(userdata); ffStrbufInitS(&device->identifier, i->name); - ffStrbufInitS(&device->platformApi, "PulseAudio"); + ffStrbufInitStatic(&device->platformApi, "PulseAudio"); ffStrbufTrimRightSpace(&device->identifier); ffStrbufInitS(&device->name, i->description); ffStrbufTrimRightSpace(&device->name); diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index e91b378f4..93edf3e46 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -105,6 +105,7 @@ void ffPrintSound(FFSoundOptions* options) { ffStrbufDestroy(&device->identifier); ffStrbufDestroy(&device->name); + ffStrbufDestroy(&device->platformApi); } } @@ -226,6 +227,7 @@ void ffGenerateSoundJsonResult(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_m { ffStrbufDestroy(&device->identifier); ffStrbufDestroy(&device->name); + ffStrbufDestroy(&device->platformApi); } }