From: Linux Karlsson Date: Wed, 20 Jul 2011 11:06:51 +0000 (+0200) Subject: [BUG 1970] UNLINK_EXPR_SLIST() causes crash if list is empty. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c10c13d58607eabb3f80792abd9e955f87b290b2;p=thirdparty%2Fntp.git [BUG 1970] UNLINK_EXPR_SLIST() causes crash if list is empty. bk: 4e26b6cb6pcvXvx-_kT_qz-rTfCKVw --- diff --git a/ChangeLog b/ChangeLog index 802b75d932..360a5e809a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ --- +* [Bug 1970] UNLINK_EXPR_SLIST() causes crash if list is empty. * [Bug 1961] html2man update: distribute ntp-wait.html. --- diff --git a/include/ntp_lists.h b/include/ntp_lists.h index ee3f9c2995..6079b83a92 100644 --- a/include/ntp_lists.h +++ b/include/ntp_lists.h @@ -42,7 +42,7 @@ * unlink entry where expression expr is nonzero. expr can refer * to the entry being tested using UNLINK_EXPR_SLIST_CURRENT(), * alias U_E_S_CUR(). See the implementation of UNLINK_SLIST() - * below for an example. + * below for an example. U_E_S_CUR() is NULL iff the list is empty. * punlinked is pointed to the removed entry or NULL if none * satisfy expr. * @@ -126,9 +126,10 @@ do { \ ppentry = &(listhead); \ \ while (!(expr)) \ - if ((*ppentry)->nextlink != NULL) \ + if ((*ppentry) != NULL && \ + (*ppentry)->nextlink != NULL) { \ ppentry = &((*ppentry)->nextlink); \ - else { \ + } else { \ ppentry = NULL; \ break; \ } \