From 2bb37f846eb78130395f3cd6a1b63b641e07aca4 Mon Sep 17 00:00:00 2001 From: Felix Walter Date: Mon, 5 Jun 2023 13:58:08 +0200 Subject: [PATCH] util/llsort: Prevent NULL pointer dereference If `_tail` is not assigned, we cannot assign `_tail->next`. Signed-off-by: Felix Walter --- external/util/include/util/llsort.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/external/util/include/util/llsort.h b/external/util/include/util/llsort.h index 5694115..b285a52 100644 --- a/external/util/include/util/llsort.h +++ b/external/util/include/util/llsort.h @@ -121,7 +121,8 @@ * and q has too */ \ _p = _q; \ } \ - _tail->next = NULL; \ + if (_tail) \ + _tail->next = NULL; \ /* If we have done only one merge, we're finished. */ \ if (_nmerges <= 1) { \ /* allow for nmerges == 0, the empty list case */ \