diff options
author | Tim Angus <tim@ngus.net> | 2012-07-07 17:32:19 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 20:46:31 +0000 |
commit | 0f1b59fc0585e79306eb5beb28822cb5e12a57dc (patch) | |
tree | 0e99e8d00c5a63588ec588bdf6f85f5cc24aa217 /src | |
parent | 8481cc3ac152bcda93507461606ce0e569958fd0 (diff) |
* (bug #5709) Fix crash when invoked with --version
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/sys_main.c | 15 | ||||
-rw-r--r-- | src/sys/sys_unix.c | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index 170107ae..bfec88eb 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -141,7 +141,12 @@ Sys_PIDFileName */ static char *Sys_PIDFileName( void ) { - return va( "%s/%s", Sys_DefaultHomePath( ), PID_FILENAME ); + const char *homePath = Sys_DefaultHomePath( ); + + if( *homePath != NULL ) + return va( "%s/%s", Sys_DefaultHomePath( ), PID_FILENAME ); + + return NULL; } /* @@ -157,6 +162,9 @@ qboolean Sys_WritePIDFile( void ) FILE *f; qboolean stale = qfalse; + if( pidFile == NULL ) + return qfalse; + // First, check if the pid file is already there if( ( f = fopen( pidFile, "r" ) ) != NULL ) { @@ -205,7 +213,10 @@ static __attribute__ ((noreturn)) void Sys_Exit( int exitCode ) if( exitCode < 2 ) { // Normal exit - remove( Sys_PIDFileName( ) ); + char *pidFile = Sys_PIDFileName( ); + + if( pidFile != NULL ) + remove( pidFile ); } Sys_PlatformExit( ); diff --git a/src/sys/sys_unix.c b/src/sys/sys_unix.c index 53a86354..b05cf855 100644 --- a/src/sys/sys_unix.c +++ b/src/sys/sys_unix.c @@ -54,7 +54,7 @@ char *Sys_DefaultHomePath(void) { char *p; - if( !*homePath ) + if( !*homePath && com_homepath != NULL ) { if( ( p = getenv( "HOME" ) ) != NULL ) { |