From 30d7276d693a45153140248bc4cf09d72c554030 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 4 May 2013 20:36:28 +0200 Subject: libdraw: fix font f->cacheimage nil dereference the initial fontresize() might fail but its error code is ignored potentially leaving f->cacheimage == nil. make sure we call fontresize() in loadchar() when theres no cacheimage and check the return value to avoid nil pointer dereference. --- sys/src/libdraw/font.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/src/libdraw/font.c b/sys/src/libdraw/font.c index 22ef0840b..cac00e1d1 100644 --- a/sys/src/libdraw/font.c +++ b/sys/src/libdraw/font.c @@ -274,7 +274,8 @@ loadchar(Font *f, Rune r, Cacheinfo *c, int h, int noflush, char **subfontname) if(fi->width == 0) goto TryPJW; wid = (fi+1)->x - fi->x; - if(f->width < wid || f->width == 0 || f->maxdepth < subf->f->bits->depth){ + if(f->width < wid || f->width == 0 || f->maxdepth < subf->f->bits->depth + || (f->display != nil && f->cacheimage == nil)){ /* * Flush, free, reload (easier than reformatting f->b) */ -- cgit v1.2.3