Skip to content
Myr

main: fix possible memory leak(s) when failing to load config

Before adoption: this commit came in with the history the project adopted, so no landing records it.

If the user has used command line options resulting in memory allocations in cmdline_overrides, and the config fails to load, we leak memory. Fix by freeing the cmdline_overrides conf in addition to the "normal" config.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent 8aa4cc3 · Browse files · 1 file+2 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−0 removed

  • other:+2 added−0 removed

1 file+2 added−0 removed

modified:main.c+2 added
1842 unmodified lines
1843 struct config conf = {0};1844 bool conf_successful = config_load(&conf, config_path, NULL, check_config);1845 if (!conf_successful) {1846 config_free(&conf);1847 config_free(&cmdline_overrides.conf);1848 return ret;1849 }18501851 if (check_config) {1852 config_free(&conf);1853 config_free(&cmdline_overrides.conf);1854 return EXIT_SUCCESS;1855 }18561857 /* Apply command line overrides */
378 unmodified lines