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.
This commit is contained in:
apocelipes 2024-05-06 11:33:50 +08:00 committed by Carter Li
parent 366138e1bd
commit 16b875ef5a

View File

@ -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();
}