[Freeswitch-svn] [commit] r6673 - freeswitch/trunk/src

Freeswitch SVN mikej at freeswitch.org
Tue Dec 11 16:31:57 EST 2007


Author: mikej
Date: Tue Dec 11 16:31:57 2007
New Revision: 6673

Modified:
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_core_hash.c
   freeswitch/trunk/src/switch_core_session.c
   freeswitch/trunk/src/switch_event.c
   freeswitch/trunk/src/switch_loadable_module.c
   freeswitch/trunk/src/switch_log.c
   freeswitch/trunk/src/switch_odbc.c
   freeswitch/trunk/src/switch_utils.c

Log:
cleanup, null checks. etc.

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Tue Dec 11 16:31:57 2007
@@ -536,7 +536,9 @@
 #ifdef WIN32
 		snprintf(path, sizeof(path), "Global\\Freeswitch.%d", getpid());
 		shutdown_event = CreateEvent(NULL, FALSE, FALSE, path);
-		WaitForSingleObject(shutdown_event, INFINITE);
+		if (shutdown_event) {
+			WaitForSingleObject(shutdown_event, INFINITE);
+		}
 #else
 		runtime.running = 1;
 		while (runtime.running) {

Modified: freeswitch/trunk/src/switch_core_hash.c
==============================================================================
--- freeswitch/trunk/src/switch_core_hash.c	(original)
+++ freeswitch/trunk/src/switch_core_hash.c	Tue Dec 11 16:31:57 2007
@@ -145,9 +145,9 @@
 {
 	if (key) {
 		*key = sqliteHashKey((HashElem *) hi);
-	}
-	if (klen) {
-		*klen = strlen((char *) *key) + 1;
+		if (klen) {
+			*klen = strlen((char *) *key) + 1;
+		}
 	}
 	if (val) {
 		*val = sqliteHashData((HashElem *) hi);

Modified: freeswitch/trunk/src/switch_core_session.c
==============================================================================
--- freeswitch/trunk/src/switch_core_session.c	(original)
+++ freeswitch/trunk/src/switch_core_session.c	Tue Dec 11 16:31:57 2007
@@ -270,13 +270,13 @@
 					int x;
 
 					for (x = 0; x < argc; x++) {
-						const char *val;
-						if ((val = switch_channel_get_variable(channel, argv[x]))) {
-							char *var = argv[x];
-							if (!strncasecmp(var, "nolocal:", 8)) {
-								var += 8;
+						const char *vval;
+						if ((vval = switch_channel_get_variable(channel, argv[x]))) {
+							char *vvar = argv[x];
+							if (!strncasecmp(vvar, "nolocal:", 8)) {
+								vvar += 8;
 							}
-							switch_channel_set_variable(peer_channel, var, val);
+							switch_channel_set_variable(peer_channel, vvar, vval);
 						}
 					}
 				}

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Tue Dec 11 16:31:57 2007
@@ -850,6 +850,7 @@
 		ret = vasprintf(&data, fmt, ap);
 #else
 		data = (char *) malloc(2048);
+		switch_assert(data);
 		ret = vsnprintf(data, 2048, fmt, ap);
 #endif
 		va_end(ap);

Modified: freeswitch/trunk/src/switch_loadable_module.c
==============================================================================
--- freeswitch/trunk/src/switch_loadable_module.c	(original)
+++ freeswitch/trunk/src/switch_loadable_module.c	Tue Dec 11 16:31:57 2007
@@ -1030,7 +1030,6 @@
 
 		while (apr_dir_read(&finfo, finfo_flags, module_dir_handle) == APR_SUCCESS) {
 			const char *fname = finfo.fname;
-			const char *err;
 
 			if (finfo.filetype != APR_REG) {
 				continue;

Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c	(original)
+++ freeswitch/trunk/src/switch_log.c	Tue Dec 11 16:31:57 2007
@@ -80,7 +80,7 @@
 	switch_assert(p);
 
 	if ((argc = switch_separate_string(p, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
-		for (x = 0; x < argc; x++) {
+		for (x = 0; x < argc && argv[x]; x++) {
 			if (!strcasecmp(argv[x], "all")) {
 				mask = 0xFF;
 				break;
@@ -221,6 +221,7 @@
 
 		len = (uint32_t) (strlen(extra_fmt) + strlen(date) + strlen(filep) + 32 + strlen(funcp) + strlen(fmt));
 		new_fmt = malloc(len + 1);
+		switch_assert(new_fmt);
 		snprintf(new_fmt, len, extra_fmt, date, switch_log_level2str(level), filep, line, funcp, 128, fmt);
 		fmt = new_fmt;
 	}

Modified: freeswitch/trunk/src/switch_odbc.c
==============================================================================
--- freeswitch/trunk/src/switch_odbc.c	(original)
+++ freeswitch/trunk/src/switch_odbc.c	Tue Dec 11 16:31:57 2007
@@ -407,9 +407,10 @@
 {
 	switch_odbc_handle_t *handle = NULL;
 
-	if (handlep) {
-		handle = *handlep;
+	if (!handlep) {
+		return;
 	}
+	handle = *handlep;
 
 	if (handle) {
 		switch_odbc_handle_disconnect(handle);

Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c	(original)
+++ freeswitch/trunk/src/switch_utils.c	Tue Dec 11 16:31:57 2007
@@ -45,7 +45,7 @@
 		s++;
 	}
 
-	if (*s == open) {
+	if (s && *s == open) {
 		depth++;
 		for (e = s + 1; e && *e; e++) {
 			if (*e == open) {
@@ -266,11 +266,11 @@
         }
 
         if (file) {
-			const char *filename = switch_cut_path(file);
+			const char *stipped_file = switch_cut_path(file);
 			const char *new_type;
 			char *ext;
 
-			if ((ext = strrchr(filename, '.'))) {
+			if ((ext = strrchr(stipped_file, '.'))) {
 				ext++;
 				if ((new_type = switch_core_mime_ext2type(ext))) {
 					mime_type = new_type;
@@ -283,7 +283,7 @@
 					 "Content-Transfer-Encoding: base64\n"
 					 "Content-Description: Sound attachment.\n"
 					 "Content-Disposition: attachment; filename=\"%s\"\n\n",
-					 bound, mime_type, filename, filename);
+					 bound, mime_type, stipped_file, stipped_file);
             if (!write_buf(fd, buf))
                 return SWITCH_FALSE;
 
@@ -379,6 +379,11 @@
 SWITCH_DECLARE(switch_bool_t) switch_ast2regex(char *pat, char *rbuf, size_t len)
 {
 	char *p = pat;
+
+	if (!pat) {
+		return SWITCH_FALSE;
+	}
+
 	memset(rbuf, 0, len);
 	
 	*(rbuf + strlen(rbuf)) = '^';
@@ -1101,6 +1106,7 @@
 	char *dest, *tmp;
 
 	dest = (char *) malloc(sizeof(char));
+	switch_assert(dest);
 
 	for (i = 0; i < string_len; i++) {
 		if (switch_string_match(string + i, string_len - i, search, search_len) == SWITCH_STATUS_SUCCESS) {



More information about the Freeswitch-svn mailing list