[Asterisk-cvs] asterisk/res res_monitor.c, 1.21, 1.21.2.1 res_odbc.c, 1.5, 1.5.2.1

citats at lists.digium.com citats at lists.digium.com
Mon Oct 25 13:53:54 CDT 2004


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

Modified Files:
      Tag: v1-0
	res_monitor.c res_odbc.c 
Log Message:
Backport recent memory fixes to 1.0

Index: res_monitor.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_monitor.c,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- res_monitor.c	17 Sep 2004 14:15:11 -0000	1.21
+++ res_monitor.c	25 Oct 2004 17:57:25 -0000	1.21.2.1
@@ -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.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- res_odbc.c	14 Jul 2004 13:57:15 -0000	1.5
+++ res_odbc.c	25 Oct 2004 17:57:25 -0000	1.5.2.1
@@ -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