You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.7 KiB

  1. commit 982bf2a0481648a0885b100cc565add399762028
  2. Author: Olivier Houchard <ohouchard@haproxy.com>
  3. Date: Tue Feb 26 18:46:07 2019 +0100
  4. BUG/MEDIUM: lists: Properly handle the case we're removing the first elt.
  5. In LIST_DEL_LOCKED(), initialize p2 to NULL, and only attempt to set it back
  6. to its previous value if we had a previous element, and thus p2 is non-NULL.
  7. (cherry picked from commit db64489aac2135c6ceceec47fe98dc42c0558466)
  8. Signed-off-by: Willy Tarreau <w@1wt.eu>
  9. (cherry picked from commit a3d6a2b9dac9775c55a10ed6b60deca219f06ff6)
  10. Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
  11. diff --git a/include/common/mini-clist.h b/include/common/mini-clist.h
  12. index b3f396ef..aebeec38 100644
  13. --- a/include/common/mini-clist.h
  14. +++ b/include/common/mini-clist.h
  15. @@ -226,7 +226,7 @@ struct cond_wordlist {
  16. do { \
  17. while (1) { \
  18. struct list *n, *n2; \
  19. - struct list *p, *p2; \
  20. + struct list *p, *p2 = NULL; \
  21. n = HA_ATOMIC_XCHG(&(el)->n, LLIST_BUSY); \
  22. if (n == LLIST_BUSY) \
  23. continue; \
  24. @@ -248,7 +248,8 @@ struct cond_wordlist {
  25. if (n != (el)) { \
  26. n2 = HA_ATOMIC_XCHG(&n->p, LLIST_BUSY); \
  27. if (n2 == LLIST_BUSY) { \
  28. - p2->n = (el); \
  29. + if (p2 != NULL) \
  30. + p2->n = (el); \
  31. (el)->p = p; \
  32. (el)->n = n; \
  33. __ha_barrier_store(); \