shithub: riscv

Download patch

ref: 30d7276d693a45153140248bc4cf09d72c554030
parent: 3e8a38dfb33e26395d63467669dbf896ec774eaa
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)
 		 */
--