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