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