Check if the fd is valid before calling close

Summary: This code calls close on fd while exiting. If the file doesn't exist the open will return -1 and close (-1) will be called.

Reviewed By: strager

Differential Revision: D15951485

fbshipit-source-id: ea3a52517847d75e9a822e51f360be7cb2c411da
This commit is contained in:
Puneet Kaushik 2019-06-21 17:01:36 -07:00 committed by Facebook Github Bot
parent 3f2dcb8ab3
commit 92f45a1b0c

View File

@ -375,7 +375,9 @@ void EdenConfig::loadConfig(
parseAndApplyConfigFile(configFd, path, configSource);
}
SCOPE_EXIT {
close(configFd);
if (configFd >= 0) {
close(configFd);
}
};
}