- avoid arithmetics with literal null pointers in ParseCommandLine.

Also avoid using longs.
This commit is contained in:
Christoph Oelckers 2023-03-26 09:49:40 +02:00
parent c1cb7783a6
commit 72d7a70732

View file

@ -74,7 +74,7 @@ CVAR(String, screenshot_type, "png", CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
CVAR(String, screenshot_dir, "", CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
EXTERN_CVAR(Bool, longsavemessages);
static long ParseCommandLine (const char *args, int *argc, char **argv);
static size_t ParseCommandLine (const char *args, int *argc, char **argv);
//---------------------------------------------------------------------------
@ -101,7 +101,7 @@ void M_FindResponseFile (void)
TArray<uint8_t> file;
int argc = 0;
int size;
long argsize = 0;
size_t argsize = 0;
int index;
// Any more response files after the limit will be removed from the
@ -179,17 +179,19 @@ void M_FindResponseFile (void)
// This is just like the version in c_dispatch.cpp, except it does not
// do cvar expansion.
static long ParseCommandLine (const char *args, int *argc, char **argv)
static size_t ParseCommandLine (const char *args, int *argc, char **argv)
{
int count;
char* buffstart;
char *buffplace;
count = 0;
buffplace = NULL;
buffstart = NULL;
if (argv != NULL)
{
buffplace = argv[0];
buffstart = argv[0];
}
buffplace = buffstart;
for (;;)
{
@ -257,7 +259,7 @@ static long ParseCommandLine (const char *args, int *argc, char **argv)
{
*argc = count;
}
return (long)(buffplace - (char *)0);
return (buffplace - buffstart);
}