+ More paratemer checking to make nitpickers happy

This commit is contained in:
unknown
2015-01-18 17:34:34 +01:00
parent e9842c38cf
commit 23ffb9d452
6 changed files with 97 additions and 83 deletions

View File

@@ -725,11 +725,20 @@ bool WINAPI SFileCreateFile(
nError = ERROR_INVALID_PARAMETER;
}
// Check for MPQs that have invalid block table size
// The number of files must not overflow the maximum
// Example: size of block table: 0x41, size of hash table: 0x40
if(nError == ERROR_SUCCESS)
{
if(ha->dwFileTableSize > ha->dwMaxFileCount)
DWORD dwReservedFiles = ha->dwReservedFiles;
if(dwReservedFiles == 0)
{
dwReservedFiles += ha->dwFileFlags1 ? 1 : 0;
dwReservedFiles += ha->dwFileFlags2 ? 1 : 0;
dwReservedFiles += ha->dwFileFlags3 ? 1 : 0;
}
if((ha->dwFileTableSize + dwReservedFiles) > ha->dwMaxFileCount)
nError = ERROR_DISK_FULL;
}