Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
Fix crash on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mittorn committed Jul 14, 2018
1 parent 3b0c90a commit 863cf02
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion engine/common/launcher.c
Expand Up @@ -49,7 +49,7 @@ int __stdcall WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int n
char **szArgv;
LPWSTR* lpArgv = CommandLineToArgvW(GetCommandLineW(), &szArgc);
int size, i = 0;
szArgv = (char**)malloc(szArgc*sizeof(char*));
szArgv = (char**)сalloc(szArgc + 1,sizeof(char*));
for (; i < szArgc; ++i)
{
size = wcslen(lpArgv[i]) + 1;
Expand Down
6 changes: 5 additions & 1 deletion engine/common/system.c
Expand Up @@ -489,7 +489,11 @@ qboolean _Sys_GetParmFromCmdLine( char *parm, char *out, size_t size )
if( !argc ) return false;
if( !out ) return false;
if( !host.argv[argc + 1] ) return false;
Q_strncpy( out, host.argv[argc+1], size );
if( argc < 0 || argc >= host.argc ) return false;
if( argc + 1 == host.argc )
Q_strncpy( out, "", size );
else
Q_strncpy( out, host.argv[argc+1], size );

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion game_launch/xash.c
Expand Up @@ -180,7 +180,7 @@ int __stdcall WinMain( HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdLine, int
int ret, i;

lpArgv = CommandLineToArgvW( GetCommandLineW(), &szArgc );
szArgv = ( char** )malloc( szArgc * sizeof( char* ));
szArgv = ( char** )сalloc( szArgc + 1, sizeof( char* ));

for( i = 0; i < szArgc; ++i )
{
Expand Down

0 comments on commit 863cf02

Please sign in to comment.