[asterisk-commits] kpfleming: branch 1.4 r201261 - /branches/1.4/include/asterisk/linkedlists.h

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 17 07:03:40 CDT 2009


Author: kpfleming
Date: Wed Jun 17 07:03:25 2009
New Revision: 201261

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=201261
Log:
Correct AST_LIST_APPEND_LIST behavior when list to be appended is empty.

When the list to be appended is empty, and the list to be appended to is *not*,
AST_LIST_APPEND_LIST would actually cause the target list to become broken,
and no longer have a pointer to its last entry. This patch fixes the problem.

(reported by Stanislaw Pitucha on the asterisk-dev mailing list)


Modified:
    branches/1.4/include/asterisk/linkedlists.h

Modified: branches/1.4/include/asterisk/linkedlists.h
URL: http://svn.asterisk.org/svn-view/asterisk/branches/1.4/include/asterisk/linkedlists.h?view=diff&rev=201261&r1=201260&r2=201261
==============================================================================
--- branches/1.4/include/asterisk/linkedlists.h (original)
+++ branches/1.4/include/asterisk/linkedlists.h Wed Jun 17 07:03:25 2009
@@ -691,15 +691,18 @@
   calling this macro (the list entries are \b moved to the target list).
  */
 #define AST_LIST_APPEND_LIST(head, list, field) do {			\
-      if (!(head)->first) {						\
+	if (!(list)->first) {						\
+		break;							\
+	}								\
+	if (!(head)->first) {						\
 		(head)->first = (list)->first;				\
 		(head)->last = (list)->last;				\
-      } else {								\
+	} else {							\
 		(head)->last->field.next = (list)->first;		\
 		(head)->last = (list)->last;				\
-      }									\
-      (list)->first = NULL;						\
-      (list)->last = NULL;						\
+	}								\
+	(list)->first = NULL;						\
+	(list)->last = NULL;						\
 } while (0)
 
 #define AST_RWLIST_APPEND_LIST AST_LIST_APPEND_LIST




More information about the asterisk-commits mailing list