[asterisk-commits] russell: branch 1.4 r51205 - /branches/1.4/funcs/func_odbc.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Jan 17 16:31:11 MST 2007


Author: russell
Date: Wed Jan 17 17:31:11 2007
New Revision: 51205

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51205
Log:
Fix some instances where when loading func_odbc, a double-free could occur.
Also, remove an unneeded error message.  If the failure condition is
actually a memory allocation failure, a log message will already be
generated automatically.

Modified:
    branches/1.4/funcs/func_odbc.c

Modified: branches/1.4/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/funcs/func_odbc.c?view=diff&rev=51205&r1=51204&r2=51205
==============================================================================
--- branches/1.4/funcs/func_odbc.c (original)
+++ branches/1.4/funcs/func_odbc.c Wed Jan 17 17:31:11 2007
@@ -363,6 +363,8 @@
 	if ((tmp = ast_variable_retrieve(cfg, catg, "dsn"))) {
 		ast_copy_string((*query)->dsn, tmp, sizeof((*query)->dsn));
 	} else {
+		free(*query);
+		*query = NULL;
 		return -1;
 	}
 
@@ -384,6 +386,7 @@
 	(*query)->acf = ast_calloc(1, sizeof(struct ast_custom_function));
 	if (! (*query)->acf) {
 		free(*query);
+		*query = NULL;
 		return -1;
 	}
 
@@ -396,6 +399,7 @@
 	if (!((*query)->acf->name)) {
 		free((*query)->acf);
 		free(*query);
+		*query = NULL;
 		return -1;
 	}
 
@@ -405,6 +409,7 @@
 		free((char *)(*query)->acf->name);
 		free((*query)->acf);
 		free(*query);
+		*query = NULL;
 		return -1;
 	}
 
@@ -440,6 +445,7 @@
 		free((char *)(*query)->acf->name);
 		free((*query)->acf);
 		free(*query);
+		*query = NULL;
 		return -1;
 	}
 
@@ -496,7 +502,6 @@
 		struct acf_odbc_query *query = NULL;
 
 		if (init_acf_query(cfg, catg, &query)) {
-			ast_log(LOG_ERROR, "Out of memory\n");
 			free_acf_query(query);
 		} else {
 			AST_LIST_INSERT_HEAD(&queries, query, list);



More information about the asterisk-commits mailing list