From 64ef4639e637287f5036cd274239f82e8bb05470 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 11 Jul 2013 17:24:28 +0000 Subject: [PATCH] Add missing checks in update_for_intended_size() in the font selector code, which would have coped badly if ever asked to select the first font in the list at a size smaller than it supported. Luckily the first font tended to be one of the X numeric aliases (e.g. 10x20) which was stored with size zero, so this probably didn't actually come up for anyone, but better safe than sorry. git-svn-id: svn://svn.tartarus.org/sgt/putty@9910 cda61777-01e9-0310-a592-d414129be87e --- unix/gtkfont.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unix/gtkfont.c b/unix/gtkfont.c index 123731a1..56ae0315 100644 --- a/unix/gtkfont.c +++ b/unix/gtkfont.c @@ -2288,6 +2288,8 @@ static fontinfo *update_for_intended_size(unifontsel_internal *fs, */ below = findrelpos234(fs->fonts_by_selorder, &info2, NULL, REL234_LE, &pos); + if (!below) + pos = -1; above = index234(fs->fonts_by_selorder, pos+1); /* @@ -2295,7 +2297,7 @@ static fontinfo *update_for_intended_size(unifontsel_internal *fs, * case. If we have, it'll be in `below' and not `above', * because we did a REL234_LE rather than REL234_LT search. */ - if (!fontinfo_selorder_compare(&info2, below)) + if (below && !fontinfo_selorder_compare(&info2, below)) return below; /* -- 2.11.0