RTech: fix bug when string is NULL

Fixes a crash because string can be NULL when this is called
This commit is contained in:
Kawe Mazidjatari 2024-01-29 22:43:55 +01:00
parent f2e49c8a4a
commit b92c2daea1

View File

@ -15,11 +15,16 @@ int FS_OpenAsyncFile(const char* const filePath, const int logLevel, size_t* con
const CHAR* fileToLoad = filePath;
char overridePath[1024];
// is this a pak file and do we have an override
if (strstr(fileToLoad, PLATFORM_PAK_PATH) &&
Pak_FileOverrideExists(fileToLoad, overridePath, sizeof(overridePath)))
// function can be called with null strings, for example if optional
// streaming sets are missing; check for it
if (fileToLoad && *fileToLoad)
{
fileToLoad = overridePath;
// is this a pak file and do we have an override
if (strstr(fileToLoad, PLATFORM_PAK_PATH) &&
Pak_FileOverrideExists(fileToLoad, overridePath, sizeof(overridePath)))
{
fileToLoad = overridePath;
}
}
const HANDLE hFile = CreateFileA(fileToLoad, GENERIC_READ,