From patchwork Fri Feb 29 13:36:47 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Schmidinger X-Patchwork-Id: 12615 Received: from raven.cadsoft.de ([217.7.101.211]) by www.linuxtv.org with esmtp (Exim 4.63) (envelope-from ) id 1JV5Pv-0007Sb-Ik for vdr@linuxtv.org; Fri, 29 Feb 2008 14:36:51 +0100 Received: from [192.168.100.10] (hawk.cadsoft.de [192.168.100.10]) by raven.cadsoft.de (8.13.3/8.13.3) with ESMTP id m1TDalDr024621 for ; Fri, 29 Feb 2008 14:36:47 +0100 Message-ID: <47C80A6F.3080406@cadsoft.de> Date: Fri, 29 Feb 2008 14:36:47 +0100 From: Klaus Schmidinger Organization: CadSoft Computer GmbH User-Agent: Thunderbird 2.0.0.9 (X11/20070801) MIME-Version: 1.0 To: vdr@linuxtv.org References: <47C74C01.40301@e-tobi.net> <47C808A2.4030602@cadsoft.de> In-Reply-To: <47C808A2.4030602@cadsoft.de> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (raven.cadsoft.de [192.168.1.1]); Fri, 29 Feb 2008 14:36:48 +0100 (CET) Subject: Re: [vdr] vdr 1.5.16 - minor problem in font.c X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Feb 2008 13:36:51 -0000 Status: O X-Status: X-Keywords: X-UID: 15899 On 02/29/08 14:29, Klaus Schmidinger wrote: > On 02/29/08 01:04, Tobi wrote: >> Hello, >> >> DrawText() in font.c uses the method Glyph() which may return a null pointer, >> but doesn't check the returned pointer. >> >> I came across this bug, when checking a bug report from Sven Mueller: >> >> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=467512 >> >> When info.vdr contains an invalid character (like in the above example a 0xA0 - >> a Latin-1 NO-BREAK SPACE), Glyph() returns null, which then causes a segfault >> when dereferencing the null-pointer. >> >> The easiest way to fix this, would probably be to ignore such invalid >> characters, which is, what the attached two-line-patch will do. But maybe it's >> better to replace such characters with a default character - maybe a space or a '?'. > > I also think showing some replacement character is best. > > Can you please verify if the attached patch does this correctly? > > If this works, I'd like to include it in version 1.6.0. Maybe the attached version is even better, because there are also other places where Glyph() is called. Klaus --- font.c 2008/02/09 11:52:25 1.23 +++ font.c 2008/02/29 13:35:15 @@ -214,6 +214,9 @@ return Glyph; } } +#define UNKNOWN_GLYPH_INDICATOR '?' + if (CharCode != UNKNOWN_GLYPH_INDICATOR) + return Glyph(UNKNOWN_GLYPH_INDICATOR); return NULL; } @@ -258,6 +261,8 @@ uint sym = Utf8CharGet(s, sl); s += sl; cGlyph *g = Glyph(sym, AntiAliased); + if (!g) + continue; int kerning = Kerning(g, prevSym); prevSym = sym; uchar *buffer = g->Bitmap();