mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix font .txt files not being null-terminated
This was an oversight when we migrated to the new UTF-8 system - it expects a null-terminated string, but the utfcpp implementation worked with a pointer to the end of the file instead. I also added an assert in FILESYSTEM_loadFileToMemory() so this is less likely to happen again - because there should be no valid reason to have a NULL pointer for the total file size, as well as not wanting a null terminator to be added at the end of the file.
This commit is contained in:
parent
4398861d50
commit
df577c59ef
2 changed files with 7 additions and 1 deletions
|
@ -741,6 +741,12 @@ void FILESYSTEM_loadFileToMemory(
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (len == NULL && !addnull)
|
||||||
|
{
|
||||||
|
vlog_warn("%s is loaded with len == NULL && !addnull", name);
|
||||||
|
SDL_assert(0 && "Are you sure you don't want a null terminator to be added to these loaded file contents?");
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: Dumb hack to use `special/stdin.vvvvvv` here...
|
/* FIXME: Dumb hack to use `special/stdin.vvvvvv` here...
|
||||||
* This is also checked elsewhere... grep for `special/stdin`! */
|
* This is also checked elsewhere... grep for `special/stdin`! */
|
||||||
if (SDL_strcmp(name, "levels/special/stdin.vvvvvv") == 0)
|
if (SDL_strcmp(name, "levels/special/stdin.vvvvvv") == 0)
|
||||||
|
|
|
@ -346,7 +346,7 @@ static uint8_t load_font(FontContainer* container, const char* name)
|
||||||
unsigned char* charmap = NULL;
|
unsigned char* charmap = NULL;
|
||||||
if (FILESYSTEM_areAssetsInSameRealDir(name_png, name_txt))
|
if (FILESYSTEM_areAssetsInSameRealDir(name_png, name_txt))
|
||||||
{
|
{
|
||||||
FILESYSTEM_loadAssetToMemory(name_txt, &charmap, NULL, false);
|
FILESYSTEM_loadAssetToMemory(name_txt, &charmap, NULL, true);
|
||||||
}
|
}
|
||||||
if (charmap != NULL)
|
if (charmap != NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue