Blame SOURCES/elinks-0.12pre6-list_is_singleton.patch

b07f02
From 701b16e0ee6f159cbf8498f4569022005dfdebbd Mon Sep 17 00:00:00 2001
b07f02
From: Kamil Dudka <kdudka@redhat.com>
b07f02
Date: Wed, 19 Mar 2014 11:48:34 +0100
b07f02
Subject: [PATCH] lists.h: list_is_singleton() now returns false for empty list
b07f02
b07f02
We have a crash report of ELinks 0.12pre6 with backtrace going through
b07f02
bookmark_all_terminals().  I believe it is caused by list_is_singleton()
b07f02
returning true for an empty list.  Consequently, bookmark_terminal()
b07f02
attempts to access a list item that does not exist.
b07f02
b07f02
While it would be possible to fix bookmark_all_terminals() to explicitly
b07f02
check the list for emptiness, I propose to fix list_is_singleton() such
b07f02
that it does not return true for an empty list.  I checked the other
b07f02
uses of list_is_singleton() and the proposed change should not introduce
b07f02
any change in the behavior elsewhere.
b07f02
b07f02
Bug: https://bugzilla.redhat.com/1075415
b07f02
---
b07f02
 src/util/lists.h | 3 ++-
b07f02
 1 file changed, 2 insertions(+), 1 deletion(-)
b07f02
b07f02
diff --git a/src/util/lists.h b/src/util/lists.h
b07f02
index b577c9f..9da38ae 100644
b07f02
--- a/src/util/lists.h
b07f02
+++ b/src/util/lists.h
b07f02
@@ -146,7 +146,8 @@ do { \
b07f02
 #define list_empty(x) (list_magic_chkbool(x, "list_empty") && (x).next == &(x))
b07f02
 
b07f02
 #define list_is_singleton(x) \
b07f02
-	(list_magic_chkbool(x, "list_is_singleton") && (x).next == (x).prev)
b07f02
+	(list_magic_chkbool(x, "list_is_singleton") && (x).next == (x).prev \
b07f02
+	&& !list_empty(x))
b07f02
 
b07f02
 #define list_has_prev(l,p) \
b07f02
 	(list_magic_chkbool(l, "list_has_prev") && (p)->prev !=  (void *) &(l))
b07f02
-- 
b07f02
1.8.3.1
b07f02