[Asterisk-cvs] asterisk/res res_monitor.c, 1.21, 1.22 res_odbc.c, 1.6, 1.7

citats at lists.digium.com citats at lists.digium.com
Sat Oct 23 02:59:03 CDT 2004


Update of /usr/cvsroot/asterisk/res
In directory mongoose.digium.com:/tmp/cvs-serv30691/res

Modified Files:
	res_monitor.c res_odbc.c 
Log Message:
More memory checks

Index: res_monitor.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_monitor.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- res_monitor.c	17 Sep 2004 14:15:11 -0000	1.21
+++ res_monitor.c	23 Oct 2004 07:03:01 -0000	1.22
@@ -90,6 +90,11 @@
 		}
 
 		monitor = malloc(sizeof(struct ast_channel_monitor));
+		if (!monitor) {
+			if (need_lock) 
+				ast_mutex_unlock(&chan->lock);
+			return -1;
+		}
 		memset(monitor, 0, sizeof(struct ast_channel_monitor));
 
 		/* Determine file names */
@@ -391,6 +396,11 @@
 	if ((!fname) || (ast_strlen_zero(fname))) {
 		// No filename base specified, default to channel name as per CLI
 		fname = malloc (FILENAME_MAX);
+		if (!fname) {
+			astman_send_error(s, m, "Could not start monitoring channel");
+			ast_mutex_unlock(&c->lock);
+			return 0;
+		}
 		memset(fname, 0, FILENAME_MAX);
 		strncpy(fname, c->name, FILENAME_MAX-1);
 		// Channels have the format technology/channel_name - have to replace that / 

Index: res_odbc.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_odbc.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- res_odbc.c	5 Oct 2004 06:46:11 -0000	1.6
+++ res_odbc.c	23 Oct 2004 07:03:01 -0000	1.7
@@ -99,10 +99,12 @@
 			if (!strcmp(cat, "ENV")) {
 				for (v = ast_variable_browse(config, cat); v; v = v->next) {
 					env_var = malloc(strlen(v->name) + strlen(v->value) + 2);
-					sprintf(env_var, "%s=%s", v->name, v->value);
-					ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value);
-					putenv(env_var);
-					free(env_var);
+					if (env_var) {
+						sprintf(env_var, "%s=%s", v->name, v->value);
+						ast_log(LOG_NOTICE, "Adding ENV var: %s=%s\n", v->name, v->value);
+						putenv(env_var);
+						free(env_var);
+					}
 				}
 
 			cat = ast_category_browse(config, cat);
@@ -222,6 +224,8 @@
 	static odbc_obj *new;
 
 	new = malloc(sizeof(odbc_obj));
+	if (!new)
+		return NULL;
 	memset(new, 0, sizeof(odbc_obj));
 	new->env = SQL_NULL_HANDLE;
 




More information about the svn-commits mailing list