I was attempting to load a file to a string via FFileHelper::LoadFileToString. This function returned true/Success, but the Result was empty. Upon further debugging, I noticed in this code that the file size was turning into a negative value. The file size was actually ~2.7GB.
From inspecting the code, it looks like the root of the issue is the following cast, which takes an int64 value and blindly casts it to an int32 value:
int64 Size = Reader.TotalSize();
…
BufferToString(Result, Ch, **(int32)**Size);
My expectation is that this function should either handle larger file sizes, or there should be some sort of safeguard in this function that tests the int64 Size value for whether it can actually fit within an int32, then provides a warning and/or failure message accordingly.
I am working on optimizing our data to avoid such a large file as a way to mitigate this issue and quickly unblock our work, but I thought I should also report it here, as it seems like it’s exposing at least one bug that should be addressed in the core code (BufferToString is also a bit suspicious in how it handles negative size values).