aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-17 12:03:25 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-17 12:03:25 +0000
commit290102abe3d3e10db82ad469d1cdf434dc186a60 (patch)
tree44db01c4e198a2c00bde721ba7c7eec1727f9e67
parente972c8d38d5d5f636f4c8994145af8a1b74d50f6 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@201261 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--include/asterisk/linkedlists.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h
index b78e7b002..f99001e7b 100644
--- a/include/asterisk/linkedlists.h
+++ b/include/asterisk/linkedlists.h
@@ -691,15 +691,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