From 82860e164b730b430f7b98419158c9d9f25c2c87 Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 29 Jan 2024 22:43:55 +0100 Subject: [PATCH] RTech: fix bug when string is NULL Fixes a crash because string can be NULL when this is called --- src/rtech/async/asyncio.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/rtech/async/asyncio.cpp b/src/rtech/async/asyncio.cpp index 1009fea3..31eecb9e 100644 --- a/src/rtech/async/asyncio.cpp +++ b/src/rtech/async/asyncio.cpp @@ -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,