[Freeswitch-svn] [commit] r8515 - freeswitch/trunk/src/mod/formats/mod_sndfile

Freeswitch SVN mikej at freeswitch.org
Wed May 21 18:40:04 EDT 2008


Author: mikej
Date: Wed May 21 18:40:04 2008
New Revision: 8515

Modified:
   freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c

Log:
don't deref NULL. Found by Klockwork (www.klocwork.com)

Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c
==============================================================================
--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c	(original)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c	Wed May 21 18:40:04 2008
@@ -323,18 +323,22 @@
 			char *p;
 			struct format_map *map = switch_core_permanent_alloc(sizeof(*map));
 			switch_assert(map);
-
+	
 			map->ext = switch_core_permanent_strdup(info.extension);
 			map->uext = switch_core_permanent_strdup(info.extension);
 			map->format = info.format;
-			for (p = map->ext; *p; p++) {
-				*p = (char) tolower(*p);
+			if (map->ext) {
+				for (p = map->ext; *p; p++) {
+					*p = (char) tolower(*p);
+				}
+				switch_core_hash_insert(globals.format_hash, map->ext, map);
 			}
-			for (p = map->uext; *p; p++) {
-				*p = (char) toupper(*p);
+			if (map->uext) {
+				for (p = map->uext; *p; p++) {
+					*p = (char) toupper(*p);
+				}
+				switch_core_hash_insert(globals.format_hash, map->uext, map);
 			}
-			switch_core_hash_insert(globals.format_hash, map->ext, map);
-			switch_core_hash_insert(globals.format_hash, map->uext, map);
 			supported_formats[len++] = (char *) info.extension;
 		}
 		format = info.format;



More information about the Freeswitch-svn mailing list