From: Mark Spencer Date: Tue, 4 Apr 2006 05:53:48 +0000 (+0000) Subject: Does nobody know how to write a linked list properly? I mean seriously! X-Git-Tag: 1.4.0-beta1~2169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f11fb652624802eaeb8f8539733d326b246c6aab;p=thirdparty%2Fasterisk.git Does nobody know how to write a linked list properly? I mean seriously! git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@17183 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/linkedlists.h b/include/asterisk/linkedlists.h index 610f8085b7..8bff72e3fa 100644 --- a/include/asterisk/linkedlists.h +++ b/include/asterisk/linkedlists.h @@ -478,11 +478,13 @@ struct { \ (head)->last = NULL; \ } else { \ typeof(elm) curelm = (head)->first; \ - while (curelm->field.next != (elm)) \ + while (curelm && (curelm->field.next != (elm))) \ curelm = curelm->field.next; \ - curelm->field.next = (elm)->field.next; \ - if ((head)->last == (elm)) \ - (head)->last = curelm; \ + if (curelm) { \ + curelm->field.next = (elm)->field.next; \ + if ((head)->last == (elm)) \ + (head)->last = curelm; \ + } \ } \ } while (0)