Floppy/Harddisk images: on failure, close handle for all return paths. (Fixes #1227)

This commit is contained in:
tomcw 2024-08-17 16:14:09 +01:00
parent 1127447a10
commit 4786de0cc7

View File

@ -68,18 +68,23 @@ ImageError_e ImageOpen( const std::string & pszImageFilename,
if (pImageInfo->pImageType && pImageInfo->pImageType->GetType() == eImageHDV)
{
if (bExpectFloppy)
{
ImageClose(*ppImageInfo);
*ppImageInfo = NULL;
Err = eIMAGE_ERROR_UNSUPPORTED_HDV;
}
return Err;
}
// THE FILE MATCHES A KNOWN FORMAT
_ASSERT(bExpectFloppy);
if (!bExpectFloppy)
return eIMAGE_ERROR_UNSUPPORTED;
if (!pImageInfo->uNumTracks)
if (!bExpectFloppy || !pImageInfo->uNumTracks)
{
ImageClose(*ppImageInfo);
*ppImageInfo = NULL;
return eIMAGE_ERROR_UNSUPPORTED;
}
*pWriteProtected = pImageInfo->bWriteProtected;