mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Always add null terminator when loading files
This removes the `addnull` argument from `FILESYSTEM_loadFileToMemory` and `FILESYSTEM_loadAssetToMemory`, and makes it so a null terminator is always appended no matter what. This simplifies things and removes the need for callers to make the decision about null termination and what its implications are. Then you get cases where null termination might not happen when it should be, such as the onedf577c59ef(#947) fixed. When FIQ added the `addnull` argument in5862af4445(#117), I'm guessing he did it because he wanted to be cautious about adding the null terminator to every file, so he only did it for XML files, which was the only case needed at the time. But really, there's no downsides to always appending a null terminator. In fact, it's already always done whenever the STDIN buffer is loaded.
This commit is contained in:
@@ -349,7 +349,7 @@ static uint8_t load_font(FontContainer* container, const char* name)
|
||||
{
|
||||
/* The .txt can contain null bytes, but it's still null-terminated - it protects
|
||||
* against incomplete sequences getting the UTF-8 decoder to read out of bounds. */
|
||||
FILESYSTEM_loadAssetToMemory(name_txt, &charmap, &length, true);
|
||||
FILESYSTEM_loadAssetToMemory(name_txt, &charmap, &length);
|
||||
}
|
||||
if (charmap != NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user