From 28d40d9037615b89f8c4e371447f54dfad0007a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 13 Sep 2023 17:42:22 +0800 Subject: [PATCH] Global: fix some memleaks --- src/modules/datetime/datetime.c | 2 +- src/modules/sound/sound.c | 6 ++++++ src/modules/terminalfont/terminalfont.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/datetime/datetime.c b/src/modules/datetime/datetime.c index 3c1644299..adc7c50cf 100644 --- a/src/modules/datetime/datetime.c +++ b/src/modules/datetime/datetime.c @@ -120,7 +120,7 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs) void ffPrintDateTime(FFDateTimeOptions* options) { uint64_t msNow = ffTimeGetNow(); - time_t sNow = msNow / 1000; + time_t sNow = (time_t) (msNow / 1000); struct tm* tm = localtime(&sNow); if(options->moduleArgs.outputFormat.length > 0) diff --git a/src/modules/sound/sound.c b/src/modules/sound/sound.c index f3efc6696..3796a7365 100644 --- a/src/modules/sound/sound.c +++ b/src/modules/sound/sound.c @@ -177,4 +177,10 @@ void ffGenerateSoundJson(FF_MAYBE_UNUSED FFSoundOptions* options, yyjson_mut_doc yyjson_mut_obj_add_strbuf(doc, obj, "name", &item->name); yyjson_mut_obj_add_strbuf(doc, obj, "identifier", &item->identifier); } + + FF_LIST_FOR_EACH(FFSoundDevice, device, result) + { + ffStrbufDestroy(&device->identifier); + ffStrbufDestroy(&device->name); + } } diff --git a/src/modules/terminalfont/terminalfont.c b/src/modules/terminalfont/terminalfont.c index 2b992912c..ca28576c9 100644 --- a/src/modules/terminalfont/terminalfont.c +++ b/src/modules/terminalfont/terminalfont.c @@ -119,4 +119,8 @@ void ffGenerateTerminalFontJson(FF_MAYBE_UNUSED FFTerminalOptions* options, yyjs yyjson_mut_arr_add_strbuf(doc, fallbackStyles, style); } yyjson_mut_obj_add_strbuf(doc, fallback, "pretty", &result.fallback.pretty); + + ffStrbufDestroy(&result.error); + ffFontDestroy(&result.font); + ffFontDestroy(&result.fallback); }