ref: 3e70ef4cf909ba4254258e176f92ab6c931993cb
parent: 66b295d461789f204d19b7181b1a11804a666728
author: Simon Howard <fraggle@soulsphere.org>
date: Wed Nov 26 14:12:09 EST 2014
hexen: Fix incorrect size on M_StringCopy(). The size parameter for the destination buffer used for this string copy was one character too short, the result being that patch lump names using the maximum length (8 characters) were having the last character cropped off. This in turn caused problems with custom WADs that added new textures with names like these: the game would exit on startup with a message like: R_InitTextures: Missing patch in texture SKY3GOLD Amazingly this bug was not noticed because most of the patches in the Hexen IWAD file have short names of 7 characters or less. The only exception I noticed was SKYWALL2 which maps to SKYWALL, another patch, hiding the bug. Thanks to ETTiNGRiNDER for reporting this bug to me and for providing me with a private copy of his in-development PWAD that I could use to find the problem.
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -314,7 +314,7 @@
patchlookup = Z_Malloc(nummappatches * sizeof(*patchlookup), PU_STATIC, NULL);
for (i = 0; i < nummappatches; i++)
{
- M_StringCopy(name, name_p + i * 8, 8);
+ M_StringCopy(name, name_p + i * 8, sizeof(name));
patchlookup[i] = W_CheckNumForName(name);
}
W_ReleaseLumpName("PNAMES");