quick and dirty fix for libhtml suicide. example of the problem: hget 'http://groups.google.com/group/comp.os.plan9/browse_thread/thread/69681ebd49278c67/3d01204ba294b513?lnk=gst&q=restricted+remote+address&rnum=1#3d01204ba294b513' | htmlfmt the token arrays are reallocated on demand, however more than one token can be lex'ed each time round the loop. My fix just ensure there is plenty of free space in the token array. -Steve Reference: /n/sources/patch/applied/libhtml-tokens Date: Thu Aug 2 13:37:00 CES 2007 Signed-off-by: steve@quintile.net --- /sys/src/libhtml/lex.c Thu Aug 2 13:33:16 2007 +++ /sys/src/libhtml/lex.c Thu Aug 2 13:33:12 2007 @@ -610,7 +610,7 @@ a = 0; if(ts->mtype == TextHtml) { for(;;) { - if(ai == alen) { + if(alen - ai < ToksChunk/32) { alen += ToksChunk; a = erealloc(a, alen*sizeof *a); } @@ -638,7 +638,7 @@ else { // plain text (non-html) tokens for(;;) { - if(ai == alen) { + if(alen - ai < ToksChunk/32) { alen += ToksChunk; a = erealloc(a, alen*sizeof *a); } @@ -1334,6 +1334,8 @@ c = -1; } break; + default: + return -1; } return c; }