]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[BUG 1970] UNLINK_EXPR_SLIST() causes crash if list is empty.
authorLinux Karlsson <karlsson@ntp.org>
Wed, 20 Jul 2011 11:06:51 +0000 (13:06 +0200)
committerLinux Karlsson <karlsson@ntp.org>
Wed, 20 Jul 2011 11:06:51 +0000 (13:06 +0200)
bk: 4e26b6cb6pcvXvx-_kT_qz-rTfCKVw

ChangeLog
include/ntp_lists.h

index 802b75d932039d88cef05a23974e66559e1134ef..360a5e809afa841a9eb39f9ee67ea88fed8831f8 100644 (file)
--- 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.
 
 ---
index ee3f9c29950b510221478273f07952b2fa2c556c..6079b83a926c946b0dc7340e2432d9dcd5ad9b50 100644 (file)
@@ -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;                                  \
                }                                               \