Check whether the file descriptor is valid

calling PosixWritableFile::Close twice should not cause segfaults
This commit is contained in:
Viktor Gal 2019-03-16 07:40:59 +01:00
parent 9dba78a2fa
commit 693aa38472

View File

@ -105,6 +105,9 @@ class PosixWritableFile : public WritableFile {
} }
Status Close() override { Status Close() override {
if (file_ == nullptr) {
return IOError(filename_, EBADF);
}
Status result; Status result;
if (fclose(file_) != 0) { if (fclose(file_) != 0) {
result = IOError(filename_, errno); result = IOError(filename_, errno);