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.
This commit is contained in:
cinap_lenrek 2013-05-04 20:36:28 +02:00
parent 3e8a38dfb3
commit 30d7276d69

View file

@ -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)
*/