summaryrefslogtreecommitdiff
path: root/src/strife/d_main.c
diff options
context:
space:
mode:
authorJames Haley2014-08-16 17:30:45 -0500
committerJames Haley2014-08-16 17:30:45 -0500
commit85221618cc9e56b4fa30af66d58031c2fb599088 (patch)
tree1ffde0d388c8601982c25bb4f3e56ec57617fd04 /src/strife/d_main.c
parent0d7f38c7513f3d8811b84e1b11b9686429f010f1 (diff)
downloadchocolate-doom-85221618cc9e56b4fa30af66d58031c2fb599088.tar.gz
chocolate-doom-85221618cc9e56b4fa30af66d58031c2fb599088.tar.bz2
chocolate-doom-85221618cc9e56b4fa30af66d58031c2fb599088.zip
Fix finding of voices.wad when -iwad is only hint
Somebody broke this by using sizeof() on a malloc'd char *
Diffstat (limited to 'src/strife/d_main.c')
-rw-r--r--src/strife/d_main.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/strife/d_main.c b/src/strife/d_main.c
index fdb6bbdc..b2eadd96 100644
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -839,19 +839,24 @@ void D_IdentifyVersion(void)
if((p = M_CheckParm("-iwad")) && p < myargc - 1)
{
char *iwad = myargv[p + 1];
- size_t len = strlen(iwad) + 24;
- char *filename = malloc(len);
- char sepchar;
-
- // how the heck is Choco surviving without this routine?
- sepchar = M_GetFilePath(iwad, filename, len);
- filename[strlen(filename)] = sepchar;
- M_StringConcat(filename, "voices.wad", sizeof(filename));
-
- if(!M_FileExists(filename))
+ size_t len = strlen(iwad) + 1;
+ char *iwadpath = Z_Malloc(len, PU_STATIC, NULL);
+ char *voiceswad;
+
+ // extract base path of IWAD parameter
+ M_GetFilePath(iwad, iwadpath, len);
+
+ // concatenate with /voices.wad
+ voiceswad = M_SafeFilePath(iwadpath, "voices.wad");
+ Z_Free(iwadpath);
+
+ if(!M_FileExists(voiceswad))
+ {
disable_voices = 1;
+ Z_Free(voiceswad);
+ }
else
- name = filename; // STRIFE-FIXME: memory leak!!
+ name = voiceswad; // STRIFE-FIXME: memory leak!!
}
else
disable_voices = 1;