From 962bd7ab2614ccb0d1133ff68a1fdb4bc64c32c2 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Wed, 17 Jun 2009 12:04:17 +0000 Subject: [PATCH] Merged revisions 201261 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r201261 | kpfleming | 2009-06-17 07:03:25 -0500 (Wed, 17 Jun 2009) | 9 lines 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) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@201262 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/linkedlists.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 52d1c53..1ee5243 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -765,15 +765,18 @@ struct { \ * 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 -- 1.7.9.5