From 888844cd3a3290baa1de4458a521d6a284165b95 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 4 Mar 2021 14:30:00 -0800 Subject: [PATCH] Fix return value of PHYSFS_fileLength() being stored in a smaller size The function returns a PHYSFS_sint64, but we forcefully shove it into a PHYSFS_uint32. This means we throw away all the negative numbers, which is bad because the function returns -1 if the size of the file can't be determined; plus, we also throw away 32 bits of information, reducing our range of supported file sizes from 9 exabytes to 4 gigabytes. File size support is only as good as the weakeast link, and it looks like one of the consumers of FILESYSTEM_loadFileToMemory(), SDL_RWFromConstMem(), only takes in a signed 32-bit integer of size; however, I would still like to do at least the bare minimum to support as many file sizes as we can, and changing types around is one of those bare minimums. --- desktop_version/src/FileSystemUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 82d50780..dd0724c8 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -360,7 +360,7 @@ void FILESYSTEM_loadFileToMemory( { return; } - PHYSFS_uint32 length = PHYSFS_fileLength(handle); + PHYSFS_sint64 length = PHYSFS_fileLength(handle); if (len != NULL) { *len = length;