[asterisk-addons-commits] mmichelson: trunk r496 - /trunk/app_addon_sql_mysql.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Wed Dec 12 11:16:41 CST 2007


Author: mmichelson
Date: Wed Dec 12 11:16:40 2007
New Revision: 496

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=496
Log:
The logic for parsing arguments in the MYSQL fetch function was incorrect.
Instead of starting at the fourth application argument, we were looping beginning
at the first. In addition to this change, I have changed the logic slightly so that
a local copy of the argument string is made instead of directly modifying the input data.

(closes issue #11343, reported by wegbert, patched by me)


Modified:
    trunk/app_addon_sql_mysql.c

Modified: trunk/app_addon_sql_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/app_addon_sql_mysql.c?view=diff&rev=496&r1=495&r2=496
==============================================================================
--- trunk/app_addon_sql_mysql.c (original)
+++ trunk/app_addon_sql_mysql.c Wed Dec 12 11:16:40 2007
@@ -362,11 +362,13 @@
 		AST_APP_ARG(fetch);
 		AST_APP_ARG(resultvar);
 		AST_APP_ARG(fetchid);
+		AST_APP_ARG(vars);
 	);
-	char *s5, *s6;
+	char *s5, *s6, *parse;
 	int resultid = -1, numFields, j;
-	
-	AST_NONSTANDARD_APP_ARGS(args, data, ' ');
+
+	parse = ast_strdupa(data);
+	AST_NONSTANDARD_APP_ARGS(args, parse, ' ');
 	sscanf(args.fetchid, "%d", &resultid);
 
 	if (args.resultvar && (resultid >= 0) ) {
@@ -375,7 +377,7 @@
 			if ((mysqlrow = mysql_fetch_row(mysqlres)) != NULL) {
 				numFields = mysql_num_fields(mysqlres);
 				for (j = 0; j < numFields; j++) {
-					s5 = strsep(&data, " ");
+					s5 = strsep(&args.vars, " ");
 					if (s5 == NULL) {
 						ast_log(LOG_WARNING, "ast_MYSQL_fetch: More fields (%d) than variables (%d)\n", numFields, j);
 						break;




More information about the asterisk-addons-commits mailing list