From 2b859633a116fbf0bc73de4e9315200648f778af Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 15 Jul 2012 19:42:09 +0200 Subject: [PATCH] fix the fix wl_reverse() for empty lists --- src/misc/wlist.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/misc/wlist.c b/src/misc/wlist.c index df90efe79..ad0557155 100644 --- a/src/misc/wlist.c +++ b/src/misc/wlist.c @@ -155,14 +155,17 @@ wl_append(wordlist *wlist, wordlist *nwl) wordlist * wl_reverse(wordlist *wl) { - while (wl) { + if (!wl) + return wl; + + for (;;) { wordlist *t = wl->wl_next; wl->wl_next = wl->wl_prev; wl->wl_prev = t; + if (!t) + return wl; wl = t; } - - return wl; }