shithub: riscv

Download patch

ref: 7c1ae2ead32396761f3f08b1ec15645dc53aae0d
parent: 15b5a980d7c2055a10567292055747b6251704f8
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Mon Aug 4 05:33:23 EDT 2014

samterm: fix ctrl-b crash when cmd window resized (thanks revex)

for reference:

On IRC revex reported that samterm crashes on Ctrl-b if the command window has
been resized. I was able to reproduce:

http://plan9.stanleylieber.com/sam/bugs/ctrl-b.png

; acid 831213
/proc/831213/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
abort()+0x0 /sys/src/libc/9sys/abort.c:6
panic1(s=0x400448)+0x27 /sys/src/cmd/samterm/main.c:692
panic()+0x19 /sys/src/cmd/samterm/main.c:684
lldelete()+0x71 /sys/src/cmd/samterm/flayer.c:221
flupfront(l=0x40eac0)+0x18 /sys/src/cmd/samterm/flayer.c:139
	v=0x20062900000001
current(nw=0x40eac0)+0x49 /sys/src/cmd/samterm/main.c:156
type(l=0x40eac0,res=0x15300000001)+0x37c /sys/src/cmd/samterm/main.c:658
	t=0x40eaa8
	buf=0x419ec0
	p=0x41dd48
	a=0x0
	backspacing=0x200000000
	c=0x41dd4800000002
	cursor=0x0
	a0=0x0
threadmain(argv=0x7ffffeffefa0)+0x21c /sys/src/cmd/samterm/main.c:75
	r=0xb0000001b1
	got=0xfefefefe00000002
	chord=0x0
	nwhich=0x43c310
	scr=0x200000000
	t=0xfefefefefefefefe
	w=0x43c310fefefefe
mainlauncher()+0x18 /sys/src/libthread/main.c:59
launcheramd64(arg=0x4194a0,f=0x221673)+0x10 /sys/src/libthread/amd64.c:11
0xfefefefefefefefe ?file?:0
acid:

--- a/sys/src/cmd/samterm/main.c
+++ b/sys/src/cmd/samterm/main.c
@@ -653,7 +653,8 @@
 		}
 	}else if(c == Kstx){
 		t = &cmd;
-		l = &t->l[0];
+		for(l=t->l; l->textfn==0; l++)
+			;
 		current(l);
 		flushtyping(0);
 		a = t->rasp.nrunes;