mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 01:11:44 +00:00
fixes a horrible uninitialized value bug with the tag-labeling system
git-svn-id: https://svn.eduke32.com/eduke32@1876 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
367afadf39
commit
bd410d8557
1 changed files with 25 additions and 9 deletions
|
@ -804,9 +804,9 @@ int32_t taglab_load(const char *filename, int32_t flags)
|
||||||
taglab_init();
|
taglab_init();
|
||||||
|
|
||||||
len = Bstrlen(filename);
|
len = Bstrlen(filename);
|
||||||
if (len >= BMAX_PATH)
|
if (len >= BMAX_PATH-1)
|
||||||
return -1;
|
return -1;
|
||||||
Bmemcpy(buf, filename, len);
|
Bmemcpy(buf, filename, len+1);
|
||||||
|
|
||||||
//
|
//
|
||||||
dot = Bstrrchr(buf, '.');
|
dot = Bstrrchr(buf, '.');
|
||||||
|
@ -9765,7 +9765,7 @@ static int32_t parseconsounds(scriptfile *script)
|
||||||
{
|
{
|
||||||
char *definedname, *filename;
|
char *definedname, *filename;
|
||||||
int32_t sndnum, ps, pe, pr, m, vo;
|
int32_t sndnum, ps, pe, pr, m, vo;
|
||||||
int32_t slen;
|
int32_t slen, duplicate=0;
|
||||||
|
|
||||||
if (scriptfile_getsymbol(script, &sndnum)) break;
|
if (scriptfile_getsymbol(script, &sndnum)) break;
|
||||||
|
|
||||||
|
@ -9776,6 +9776,7 @@ static int32_t parseconsounds(scriptfile *script)
|
||||||
{
|
{
|
||||||
initprintf("Warning: invalid sound definition %s (sound number < 0 or >= MAXSOUNDS) on line %s:%d\n",
|
initprintf("Warning: invalid sound definition %s (sound number < 0 or >= MAXSOUNDS) on line %s:%d\n",
|
||||||
definedname, script->filename,scriptfile_getlinum(script,cmdtokptr));
|
definedname, script->filename,scriptfile_getlinum(script,cmdtokptr));
|
||||||
|
Bfree(definedname);
|
||||||
num_invalidsounds++;
|
num_invalidsounds++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -9797,8 +9798,12 @@ static int32_t parseconsounds(scriptfile *script)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_sounds[sndnum].filename == NULL)
|
if (g_sounds[sndnum].filename)
|
||||||
g_sounds[sndnum].filename = Bcalloc(slen+1,sizeof(uint8_t));
|
{
|
||||||
|
duplicate = 1;
|
||||||
|
Bfree(g_sounds[sndnum].filename);
|
||||||
|
}
|
||||||
|
g_sounds[sndnum].filename = Bcalloc(slen+1,sizeof(uint8_t));
|
||||||
// Hopefully noone does memcpy(..., g_sounds[].filename, BMAX_PATH)
|
// Hopefully noone does memcpy(..., g_sounds[].filename, BMAX_PATH)
|
||||||
if (!g_sounds[sndnum].filename)
|
if (!g_sounds[sndnum].filename)
|
||||||
{
|
{
|
||||||
|
@ -9823,16 +9828,27 @@ BAD:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_sounds[sndnum].definedname)
|
||||||
|
{
|
||||||
|
duplicate = 1;
|
||||||
|
Bfree(g_sounds[sndnum].definedname);
|
||||||
|
}
|
||||||
|
if (duplicate)
|
||||||
|
initprintf("warning: duplicate sound #%d, overwriting\n", sndnum);
|
||||||
|
|
||||||
g_sounds[sndnum].definedname = definedname; // we want to keep it for display purposes
|
g_sounds[sndnum].definedname = definedname; // we want to keep it for display purposes
|
||||||
g_sounds[sndnum].ps = ps;
|
g_sounds[sndnum].ps = ps;
|
||||||
g_sounds[sndnum].pe = pe;
|
g_sounds[sndnum].pe = pe;
|
||||||
g_sounds[sndnum].pr = pr;
|
g_sounds[sndnum].pr = pr;
|
||||||
g_sounds[sndnum].m = m;
|
g_sounds[sndnum].m = m;
|
||||||
g_sounds[sndnum].vo = vo;
|
g_sounds[sndnum].vo = vo;
|
||||||
g_sndnum[g_numsounds] = g_definedsndnum[g_numsounds] = sndnum;
|
if (!duplicate)
|
||||||
g_numsounds++;
|
{
|
||||||
if (g_numsounds == MAXSOUNDS)
|
g_sndnum[g_numsounds] = g_definedsndnum[g_numsounds] = sndnum;
|
||||||
goto END;
|
g_numsounds++;
|
||||||
|
if (g_numsounds == MAXSOUNDS)
|
||||||
|
goto END;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
|
|
Loading…
Reference in a new issue