Check getcwd return in X11 platform main.

This commit is contained in:
Fabio Alessandrelli 2018-10-06 07:14:28 +02:00
parent 67177586d3
commit f8020bc976

View File

@ -43,7 +43,7 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
char *cwd = (char *)malloc(PATH_MAX);
getcwd(cwd, PATH_MAX);
char *ret = getcwd(cwd, PATH_MAX);
Error err = Main::setup(argv[0], argc - 1, &argv[1]);
if (err != OK) {
@ -55,7 +55,8 @@ int main(int argc, char *argv[]) {
os.run(); // it is actually the OS that decides how to run
Main::cleanup();
chdir(cwd);
if (ret)
chdir(cwd);
free(cwd);
return os.get_exit_code();