Windows: Release handle/fd when file open fails #6699

This commit is contained in:
Christian Kamm 2018-08-14 13:02:45 +02:00 committed by Camila San
parent 90d3917481
commit 4bd2545dad
No known key found for this signature in database
GPG key ID: 7A4A6121E88E2AD4

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;
}