From 16b875ef5ab4113f6278622c7fc44a3502b07533 Mon Sep 17 00:00:00 2001 From: apocelipes Date: Mon, 6 May 2024 11:33:50 +0800 Subject: [PATCH] Fastfetch: fix memory leaks when passing informative options Informative options (e.g. "--help", "--list-module") make fastfetch exit before calling ffDestroyInstance. Using "atexit" to avoid this kind of leak. --- src/fastfetch.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fastfetch.c b/src/fastfetch.c index 474abd78f..a57b0a3f4 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -863,6 +863,7 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename) int main(int argc, char** argv) { ffInitInstance(); + atexit(ffDestroyInstance); //Data stores things only needed for the configuration of fastfetch FFdata data = { @@ -888,6 +889,4 @@ int main(int argc, char** argv) ffStrbufDestroy(&customValue->value); } ffListDestroy(&data.customValues); - - ffDestroyInstance(); }