mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-12-26 20:31:30 +00:00
Merge branch 'responsefile-fix' into 'master'
Fix M_FindResponseFile returning garbage data See merge request STJr/SRB2!254
This commit is contained in:
commit
d228e35fcb
5 changed files with 15 additions and 5 deletions
11
src/m_argv.c
11
src/m_argv.c
|
@ -2,7 +2,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1993-1996 by id Software, Inc.
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2016 by Sonic Team Junior.
|
||||
// Copyright (C) 1999-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
|
@ -25,6 +25,10 @@ INT32 myargc;
|
|||
*/
|
||||
char **myargv;
|
||||
|
||||
/** \brief did we alloc myargv ourselves?
|
||||
*/
|
||||
boolean myargmalloc = false;
|
||||
|
||||
/** \brief founded the parm
|
||||
*/
|
||||
static INT32 found;
|
||||
|
@ -176,6 +180,7 @@ void M_FindResponseFile(void)
|
|||
free(file);
|
||||
I_Error("Not enough memory to read response file");
|
||||
}
|
||||
myargmalloc = true; // mark as having been allocated by us
|
||||
memset(myargv, 0, sizeof (char *) * MAXARGVS);
|
||||
myargv[0] = firstargv;
|
||||
|
||||
|
@ -198,14 +203,12 @@ void M_FindResponseFile(void)
|
|||
k++;
|
||||
} while (k < size);
|
||||
|
||||
free(file);
|
||||
|
||||
for (k = 0; k < pindex; k++)
|
||||
myargv[indexinfile++] = moreargs[k];
|
||||
myargc = indexinfile;
|
||||
|
||||
// display arguments
|
||||
CONS_Printf(M_GetText("%d command-line args:\n"), myargc);
|
||||
CONS_Printf(M_GetText("%d command-line args:\n"), myargc-1); // -1 so @ don't actually get counted for
|
||||
for (k = 1; k < myargc; k++)
|
||||
CONS_Printf("%s\n", myargv[k]);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
//
|
||||
extern INT32 myargc;
|
||||
extern char **myargv;
|
||||
extern boolean myargmalloc;
|
||||
|
||||
// Returns the position of the given parameter in the arg list (0 if not found).
|
||||
INT32 M_CheckParm(const char *check);
|
||||
|
|
|
@ -2139,6 +2139,8 @@ void I_Quit(void)
|
|||
printf("\r");
|
||||
ShowEndTxt();
|
||||
}
|
||||
if (myargmalloc)
|
||||
free(myargv); // Deallocate allocated memory
|
||||
death:
|
||||
W_Shutdown();
|
||||
exit(0);
|
||||
|
|
|
@ -2301,6 +2301,8 @@ void I_Quit(void)
|
|||
printf("\r");
|
||||
ShowEndTxt();
|
||||
}
|
||||
if (myargmalloc)
|
||||
free(myargv); // Deallocate allocated memory
|
||||
death:
|
||||
W_Shutdown();
|
||||
#ifdef GP2X
|
||||
|
|
|
@ -771,6 +771,8 @@ void I_Quit(void)
|
|||
ShowEndTxt(co);
|
||||
}
|
||||
fflush(stderr);
|
||||
if (myargmalloc)
|
||||
free(myargv); // Deallocate allocated memory
|
||||
W_Shutdown();
|
||||
exit(0);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue