git: 9front

Download patch

ref: 8db43f0629e70f8253047e5756ae63471aa96e6f
parent: c3618bcd6310b3db1c96506a4914accac4775fc6
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat May 4 16:36:28 EDT 2013

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.

--- a/sys/src/libdraw/font.c
+++ b/sys/src/libdraw/font.c
@@ -274,7 +274,8 @@
 	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)
 		 */
--