summaryrefslogtreecommitdiff
path: root/sys/src/libdraw
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-05-04 20:36:28 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-05-04 20:36:28 +0200
commit30d7276d693a45153140248bc4cf09d72c554030 (patch)
treebd6ed89736c0105b4fd21773b9f52835210600de /sys/src/libdraw
parent3e8a38dfb33e26395d63467669dbf896ec774eaa (diff)
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.
Diffstat (limited to 'sys/src/libdraw')
-rw-r--r--sys/src/libdraw/font.c3
1 files changed, 2 insertions, 1 deletions
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)
*/