From d366e7729af94da62f4dec7f434ef4cfe5c55353 Mon Sep 17 00:00:00 2001 From: tilghman Date: Sun, 11 Dec 2005 01:26:51 +0000 Subject: Bug 5965 - major bug in AST_LIST_REMOVE git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@7429 f38db490-d61c-443f-a65b-d21fe96a405b --- include/asterisk/linkedlists.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include/asterisk') diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index cfe846225..f687189e2 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -424,15 +424,16 @@ struct { \ #define AST_LIST_REMOVE(head, elm, field) do { \ if ((head)->first == (elm)) { \ (head)->first = (elm)->field.next; \ - } \ - else { \ + if ((head)->last = (elm)) \ + (head)->last = NULL; \ + } else { \ typeof(elm) curelm = (head)->first; \ while (curelm->field.next != (elm)) \ curelm = curelm->field.next; \ curelm->field.next = (elm)->field.next; \ + if ((head)->last == curelm->field.next) \ + (head)->last = curelm; \ } \ - if ((head)->last == elm) \ - (head)->last = NULL; \ } while (0) #endif /* _ASTERISK_LINKEDLISTS_H */ -- cgit v1.2.3