[svn-commits] twilson: branch twilson/res_config_sqlite3 r334433 - /team/twilson/res_config...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Sep 3 23:01:02 CDT 2011


Author: twilson
Date: Sat Sep  3 23:00:51 2011
New Revision: 334433

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=334433
Log:
Insert variables at tail because of silly allow/disallow

Modified:
    team/twilson/res_config_sqlite3/res/res_config_sqlite3.c

Modified: team/twilson/res_config_sqlite3/res/res_config_sqlite3.c
URL: http://svnview.digium.com/svn/asterisk/team/twilson/res_config_sqlite3/res/res_config_sqlite3.c?view=diff&rev=334433&r1=334432&r2=334433
==============================================================================
--- team/twilson/res_config_sqlite3/res/res_config_sqlite3.c (original)
+++ team/twilson/res_config_sqlite3/res/res_config_sqlite3.c Sat Sep  3 23:00:51 2011
@@ -426,15 +426,23 @@
 /*! \brief Create a varlist from a single sqlite3 result row */
 static int row_to_varlist(void *arg, int num_columns, char **values, char **columns)
 {
-	struct ast_variable **head = arg;
+	struct ast_variable **head = arg, *tail;
 	int i;
-
-	/* reverse order, but who cares? */
-	for (i = 0; i < num_columns; i++) {
-		struct ast_variable *new;
-		new = ast_variable_new(columns[i], values[i], "");
-		new->next = *head;
-		*head = new;
+	struct ast_variable *new;
+
+	if (!(new = ast_variable_new(columns[0], values[0], ""))) {
+		return SQLITE_ABORT;
+	}
+	*head = tail = new;
+
+	for (i = 1; i < num_columns; i++) {
+		if (!(new = ast_variable_new(columns[i], values[i], ""))) {
+			ast_variables_destroy(*head);
+			*head = NULL;
+			return SQLITE_ABORT;
+		}
+		tail->next = new;
+		tail = new;
 	}
 
 	return 0;




More information about the svn-commits mailing list