Merge pull request #663 from nextcloud/upstream/pr/6707

Windows: Release handle/fd when file open fails #6699
This commit is contained in:
Roeland Jago Douma 2018-10-30 22:40:44 +01:00 committed by GitHub
commit 326c872ba7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -272,10 +272,12 @@ bool FileSystem::openAndSeekFileSharedRead(QFile *file, QString *errorOrNull, qi
int fd = _open_osfhandle((intptr_t)fileHandle, _O_RDONLY);
if (fd == -1) {
error = "could not make fd from handle";
CloseHandle(fileHandle);
return false;
}
if (!file->open(fd, QIODevice::ReadOnly, QFile::AutoCloseHandle)) {
error = file->errorString();
_close(fd); // implicitly closes fileHandle
return false;
}