Skip to content

Commit 16b875e

Browse files
apocelipesCarterLi
authored andcommitted
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.
1 parent 366138e commit 16b875e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/fastfetch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,7 @@ static void writeConfigFile(FFdata* data, const FFstrbuf* filename)
863863
int main(int argc, char** argv)
864864
{
865865
ffInitInstance();
866+
atexit(ffDestroyInstance);
866867

867868
//Data stores things only needed for the configuration of fastfetch
868869
FFdata data = {
@@ -888,6 +889,4 @@ int main(int argc, char** argv)
888889
ffStrbufDestroy(&customValue->value);
889890
}
890891
ffListDestroy(&data.customValues);
891-
892-
ffDestroyInstance();
893892
}

0 commit comments

Comments
 (0)