git: 9front

Download patch

ref: 31413c988e38ca2ed2014207ace1441394d38f03
parent: 3efdb2b9413b035f0b257265732a912a58b93825
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat May 25 00:36:16 EDT 2013

libdraw: fix agefont crash when display == nil (from sources / agefont-nodisplay patch)

If you run this:
	{for (i in `{seq 1 70000}) echo '½•α·'} | mc | wc
mc will eventually suicide. The error comes from
/sys/src/libdraw/font.c:/^agefont which assumes it has a
display. Normally, this is set up by geninitdraw (usually
via initdraw), but mc.c avoids that to avoid the screen
redraws (flicker, at a minimum, but worse in long-running
cases).

graphics(2) does not prohibit this use, so I made the least
intrusive change to make it work.

--- a/sys/src/libdraw/font.c
+++ b/sys/src/libdraw/font.c
@@ -129,7 +129,7 @@
 			if(s->age){
 				if(s->age<SUBFAGE && s->cf->name != nil){
 					/* clean up */
-					if(s->f != display->defaultsubfont)
+					if(display == nil || s->f != display->defaultsubfont)
 						freesubfont(s->f);
 					s->cf = nil;
 					s->f = nil;
--