Merge pull request #10598 from Rubonnek/free-memory

Free memory when Main::setup returns an error
This commit is contained in:
Rémi Verschelde 2017-08-27 02:10:41 +02:00 committed by GitHub
commit ea55b400d9
2 changed files with 9 additions and 2 deletions

View file

@ -136,8 +136,13 @@ int widechar_main(int argc, wchar_t **argv) {
Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]); Error err = Main::setup(argv_utf8[0], argc - 1, &argv_utf8[1]);
if (err != OK) if (err != OK) {
for (int i = 0; i < argc; ++i) {
delete[] argv_utf8[i];
}
delete[] argv_utf8;
return 255; return 255;
}
if (Main::start()) if (Main::start())
os.run(); os.run();

View file

@ -45,8 +45,10 @@ int main(int argc, char *argv[]) {
getcwd(cwd, PATH_MAX); getcwd(cwd, PATH_MAX);
Error err = Main::setup(argv[0], argc - 1, &argv[1]); Error err = Main::setup(argv[0], argc - 1, &argv[1]);
if (err != OK) if (err != OK) {
free(cwd);
return 255; return 255;
}
if (Main::start()) if (Main::start())
os.run(); // it is actually the OS that decides how to run os.run(); // it is actually the OS that decides how to run