[Asterisk-cvs] asterisk-addons res_config_mysql.c,1.2,1.3

markster at lists.digium.com markster at lists.digium.com
Wed Jan 19 22:51:32 CST 2005


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

Modified Files:
	res_config_mysql.c 
Log Message:
Fix initialization of files in the multi functions (bug #3379)


Index: res_config_mysql.c
===================================================================
RCS file: /usr/cvsroot/asterisk-addons/res_config_mysql.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- res_config_mysql.c	7 Jan 2005 19:13:49 -0000	1.2
+++ res_config_mysql.c	20 Jan 2005 04:54:33 -0000	1.3
@@ -173,6 +173,7 @@
 	char *chunk;
 	char *op;
 	const char *newparam, *newval;
+	struct ast_realloca ra;
 	struct ast_variable *var=NULL, *prev=NULL;
 	struct ast_config *cfg = NULL;
 	struct ast_category *cat = NULL;
@@ -181,6 +182,8 @@
 		ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
 		return NULL;
 	}
+	
+	memset(&ra, 0, sizeof(ra));
 
 	/* Get the first parameter and first value in our list of passed paramater/value pairs */
 	newparam = va_arg(ap, const char *);
@@ -234,16 +237,19 @@
 	numFields = mysql_num_fields(result);
 	fields = mysql_fetch_fields(result);
 
-	while((row = mysql_fetch_row(result))) {
+	while ((row = mysql_fetch_row(result))) {
+		var = NULL;
+		prev = NULL;
+		title = NULL;
 		for(i = 0; i < numFields; i++) {
 			stringp = row[i];
 			while(stringp) {
 				chunk = strsep(&stringp, ";");
 				if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
-					if(initfield && !strcmp(initfield, fields[i].name) && !title) {
-						title = ast_strdupa(chunk);
+					if (initfield && !strcmp(initfield, fields[i].name) && !title) {
+						title = ast_restrdupa(&ra, chunk);
 					}
-					if(prev) {
+					if (prev) {
 						prev->next = ast_new_variable(fields[i].name, chunk);
 						if (prev->next) {
 							prev = prev->next;




More information about the svn-commits mailing list