[quake3-commits] r2361 - trunk/code/client

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Nov 18 19:40:03 EST 2012


Author: ztm
Date: 2012-11-18 19:40:03 -0500 (Sun, 18 Nov 2012)
New Revision: 2361

Modified:
   trunk/code/client/snd_dma.c
   trunk/code/client/snd_openal.c
Log:
- Check for invalid filename in OpenAL's RegisterSound function.
- Changed Base sound system to warn not error when sound filename is empty or too long.

Modified: trunk/code/client/snd_dma.c
===================================================================
--- trunk/code/client/snd_dma.c	2012-11-18 23:30:26 UTC (rev 2360)
+++ trunk/code/client/snd_dma.c	2012-11-19 00:40:03 UTC (rev 2361)
@@ -258,14 +258,17 @@
 	sfx_t	*sfx;
 
 	if (!name) {
-		Com_Error (ERR_FATAL, "S_FindName: NULL");
+		Com_Error(ERR_FATAL, "Sound name is NULL");
 	}
+
 	if (!name[0]) {
-		Com_Error (ERR_FATAL, "S_FindName: empty name");
+		Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" );
+		return NULL;
 	}
 
 	if (strlen(name) >= MAX_QPATH) {
-		Com_Error (ERR_FATAL, "Sound name too long: %s", name);
+		Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", name );
+		return NULL;
 	}
 
 	hash = S_HashSFXName(name);
@@ -351,12 +354,11 @@
 		return 0;
 	}
 
-	if ( strlen( name ) >= MAX_QPATH ) {
-		Com_Printf( "Sound name exceeds MAX_QPATH\n" );
+	sfx = S_FindName( name );
+	if ( !sfx ) {
 		return 0;
 	}
 
-	sfx = S_FindName( name );
 	if ( sfx->soundData ) {
 		if ( sfx->defaultSound ) {
 			Com_Printf( S_COLOR_YELLOW "WARNING: could not find %s - using default\n", sfx->soundName );

Modified: trunk/code/client/snd_openal.c
===================================================================
--- trunk/code/client/snd_openal.c	2012-11-18 23:30:26 UTC (rev 2360)
+++ trunk/code/client/snd_openal.c	2012-11-19 00:40:03 UTC (rev 2361)
@@ -194,6 +194,20 @@
 	sfxHandle_t sfx = -1;
 	int i;
 
+	if ( !filename ) {
+		Com_Error( ERR_FATAL, "Sound name is NULL" );
+	}
+
+	if ( !filename[0] ) {
+		Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is empty\n" );
+		return 0;
+	}
+
+	if ( strlen( filename ) >= MAX_QPATH ) {
+		Com_Printf( S_COLOR_YELLOW "WARNING: Sound name is too long: %s\n", filename );
+		return 0;
+	}
+
 	for(i = 0; i < numSfx; i++)
 	{
 		if(!Q_stricmp(knownSfx[i].filename, filename))



More information about the quake3-commits mailing list