Skip to content

Commit

Permalink
Initial ASAN leaks check
Browse files Browse the repository at this point in the history
  • Loading branch information
erysdren committed Jul 12, 2024
1 parent 5330270 commit 32dcda8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 40 deletions.
3 changes: 1 addition & 2 deletions rott/rt_datadir.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,11 @@ char *FindFileByName(const char *name)
path = M_StringJoin(datadirs[i], PATH_SEP_STR, name, NULL);

probe = M_FileCaseExists(path);
free(path);
if (probe != NULL)
{
return probe;
}

free(path);
}

// File not found
Expand Down
5 changes: 5 additions & 0 deletions rott/rt_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,11 @@ NoRTC:;
newargs [argnum++] = NULL;

W_InitMultipleFiles(newargs);

for (int i = 0; i < argnum; i++)
{
free(newargs[i]);
}
}

void PlayTurboGame
Expand Down
71 changes: 33 additions & 38 deletions rott/scriplib.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ void UnGetToken (void)
==============
*/

void GetToken (boolean crossline)
void GetToken(boolean crossline)
{
char *token_p;
char *token_p;

if (tokenready) // is a token allready waiting?
if (tokenready) // is a token allready waiting?
{
tokenready = false;
return;
Expand All @@ -109,72 +109,67 @@ void GetToken (boolean crossline)
if (script_p >= scriptend_p)
{
if (!crossline)
Error ("Line %i is incomplete\nin file %s\n",
scriptline,scriptfilename);
Error("Line %i is incomplete\nin file %s\n", scriptline, scriptfilename);

endofscript = true;
return;
}

//
// skip space
//
skipspace:
while (*script_p <= 32)
//
// skip space
//
skipspace:
while (script_p < scriptend_p && *script_p <= 32)
{
if (script_p >= scriptend_p)
{
if (!crossline)
Error ("Line %i is incomplete\nin file %s\n",
scriptline,scriptfilename);
endofscript = true;
return;
}
if (*script_p++ == '\n')
{
if (!crossline)
Error ("Line %i is incomplete\nin file %s\n",
scriptline,scriptfilename);
Error("Line %i is incomplete\nin file %s\n", scriptline, scriptfilename);

scriptline++;
}
}

if (script_p >= scriptend_p)
{
if (!crossline)
Error ("Line %i is incomplete\nin file %s\n",
scriptline,scriptfilename);
Error("Line %i is incomplete\nin file %s\n", scriptline, scriptfilename);

endofscript = true;
return;
}

if (*script_p == ';') // semicolon is comment field
if (*script_p == ';') // semicolon is comment field
{
if (!crossline)
Error ("Line %i is incomplete\nin file %s\n",
scriptline,scriptfilename);
while (*script_p++ != '\n')
if (script_p >= scriptend_p)
{
endofscript = true;
return;
}
Error("Line %i is incomplete\nin file %s\n", scriptline, scriptfilename);

while (script_p < scriptend_p && *script_p != '\n')
script_p++;

if (script_p >= scriptend_p)
{
endofscript = true;
return;
}

goto skipspace;
}

//
// copy token
//
//
// copy token
//
token_p = token;

while ( *script_p > 32 && *script_p != ';')
while (*script_p > 32 && *script_p != ';')
{
*token_p++ = *script_p++;
if (script_p == scriptend_p)
break;
if (token_p == &token[MAXTOKEN])
Error ("Token too large on line %i\nin file %s\n",
scriptline,scriptfilename);
}
Error("Token too large on line %i\nin file %s\n", scriptline,
scriptfilename);
}

*token_p = 0;
}
Expand Down

0 comments on commit 32dcda8

Please sign in to comment.