[quake3-commits] r2300 - trunk/code/sys

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Jul 7 13:32:19 EDT 2012


Author: tma
Date: 2012-07-07 13:32:19 -0400 (Sat, 07 Jul 2012)
New Revision: 2300

Modified:
   trunk/code/sys/sys_main.c
   trunk/code/sys/sys_unix.c
Log:
* (bug #5709) Fix crash when invoked with --version

Modified: trunk/code/sys/sys_main.c
===================================================================
--- trunk/code/sys/sys_main.c	2012-07-05 13:42:08 UTC (rev 2299)
+++ trunk/code/sys/sys_main.c	2012-07-07 17:32:19 UTC (rev 2300)
@@ -140,7 +140,12 @@
 */
 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;
 }
 
 /*
@@ -156,6 +161,9 @@
 	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 )
 	{
@@ -204,7 +212,10 @@
 	if( exitCode < 2 )
 	{
 		// Normal exit
-		remove( Sys_PIDFileName( ) );
+		char *pidFile = Sys_PIDFileName( );
+
+		if( pidFile != NULL )
+			remove( pidFile );
 	}
 
 	Sys_PlatformExit( );

Modified: trunk/code/sys/sys_unix.c
===================================================================
--- trunk/code/sys/sys_unix.c	2012-07-05 13:42:08 UTC (rev 2299)
+++ trunk/code/sys/sys_unix.c	2012-07-07 17:32:19 UTC (rev 2300)
@@ -53,7 +53,7 @@
 {
 	char *p;
 
-	if( !*homePath )
+	if( !*homePath && com_homepath != NULL )
 	{
 		if( ( p = getenv( "HOME" ) ) != NULL )
 		{



More information about the quake3-commits mailing list