let list_is_singleton() return false for an empty list (#1075415)

This commit is contained in:
Kamil Dudka 2014-04-29 11:25:04 +02:00
parent 135272d2c8
commit f3464b7f8e
2 changed files with 46 additions and 1 deletions

View File

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

View File

@ -3,7 +3,7 @@
Name: elinks
Summary: A text-mode Web browser
Version: 0.12
Release: 0.37.%{prerel}%{?dist}
Release: 0.38.%{prerel}%{?dist}
License: GPLv2
URL: http://elinks.or.cz
Group: Applications/Internet
@ -42,6 +42,7 @@ Patch11: elinks-0.12pre5-js185.patch
Patch12: elinks-0.12pre5-ddg-search.patch
Patch13: elinks-0.12pre6-autoconf.patch
Patch14: elinks-0.12pre6-ssl-hostname.patch
Patch15: elinks-0.12pre6-list_is_singleton.patch
%description
Elinks is a text-based Web browser. Elinks does not display any images,
@ -91,6 +92,9 @@ quickly and swiftly displays Web pages.
# verify server certificate hostname with nss_compat_ossl (#881411)
%patch14 -p1
# let list_is_singleton() return false for an empty list (#1075415)
%patch15 -p1
# remove bogus serial numbers
sed -i 's/^# *serial [AM0-9]*$//' acinclude.m4 config/m4/*.m4
@ -159,6 +163,9 @@ exit 0
%{_mandir}/man5/*
%changelog
* Tue Apr 29 2014 Kamil Dudka <kdudka@redhat.com> - 0.12-0.38.pre6
- let list_is_singleton() return false for an empty list (#1075415)
* Wed Sep 18 2013 Kamil Dudka <kdudka@redhat.com> - 0.12-0.37.pre6
- verify server certificate hostname with nss_compat_ossl (#881411)