foxygit / doom Log in
commit 3e70ef4cf909ba4254258e176f92ab6c931993cb
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Wed Nov 26 19:12:09 2014 -0500
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Wed Nov 26 19:16:05 2014 -0500

    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.
---
 src/hexen/r_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/hexen/r_data.c b/src/hexen/r_data.c
index d9f76bcb..e99ecc21 100644
--- a/src/hexen/r_data.c
+++ b/src/hexen/r_data.c
@@ -314,7 +314,7 @@ void R_InitTextures(void)
     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");