Merge pull request #29850 from akien-mga/x11-check-chdir

Linux: Check return value of chdir on cleanup
This commit is contained in:
Rémi Verschelde 2019-06-17 17:24:55 +02:00 committed by GitHub
commit 813c0d8474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,8 +55,11 @@ int main(int argc, char *argv[]) {
os.run(); // it is actually the OS that decides how to run
Main::cleanup();
if (ret)
chdir(cwd);
if (ret) { // Previous getcwd was successful
if (chdir(cwd) != 0) {
ERR_PRINT("Couldn't return to previous working directory.");
}
}
free(cwd);
return os.get_exit_code();