mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
libdraw, libframe, acme: fix, guard against inverted range in textsetselect
Credit to Roi Martin <jroi.martin@gmail.com> for noticing that libdraw was being passed a negative string length and for finding the sequence of keystrokes that make acme do it reproducibly. Change-Id: If3f3d04a25c506175f740d3e887d5d83b5cd1bfe Reviewed-on: https://plan9port-review.googlesource.com/1092 Reviewed-by: Russ Cox <rsc@swtch.com>
This commit is contained in:
parent
d3a47e14e5
commit
fff818fe87
3 changed files with 15 additions and 3 deletions
|
@ -819,8 +819,12 @@ texttype(Text *t, Rune r)
|
||||||
nr = runestrlen(rp);
|
nr = runestrlen(rp);
|
||||||
break; /* fall through to normal insertion case */
|
break; /* fall through to normal insertion case */
|
||||||
case 0x1B:
|
case 0x1B:
|
||||||
if(t->eq0 != ~0)
|
if(t->eq0 != ~0) {
|
||||||
|
if(t->eq0 <= t->q0)
|
||||||
textsetselect(t, t->eq0, t->q0);
|
textsetselect(t, t->eq0, t->q0);
|
||||||
|
else
|
||||||
|
textsetselect(t, t->q0, t->eq0);
|
||||||
|
}
|
||||||
if(t->ncache > 0)
|
if(t->ncache > 0)
|
||||||
typecommit(t);
|
typecommit(t);
|
||||||
t->iq1 = t->q0;
|
t->iq1 = t->q0;
|
||||||
|
@ -1198,6 +1202,8 @@ textsetselect(Text *t, uint q0, uint q1)
|
||||||
frtick(&t->fr, frptofchar(&t->fr, p0), ticked);
|
frtick(&t->fr, frptofchar(&t->fr, p0), ticked);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(p0 > p1)
|
||||||
|
sysfatal("acme: textsetselect p0=%d p1=%d q0=%ud q1=%ud t->org=%d nchars=%d", p0, p1, q0, q1, (int)t->org, (int)t->fr.nchars);
|
||||||
/* screen disagrees with desired selection */
|
/* screen disagrees with desired selection */
|
||||||
if(t->fr.p1<=p0 || p1<=t->fr.p0 || p0==p1 || t->fr.p1==t->fr.p0){
|
if(t->fr.p1<=p0 || p1<=t->fr.p0 || p0==p1 || t->fr.p1==t->fr.p0){
|
||||||
/* no overlap or too easy to bother trying */
|
/* no overlap or too easy to bother trying */
|
||||||
|
|
|
@ -67,6 +67,9 @@ _string(Image *dst, Point pt, Image *src, Point sp, Font *f, char *s, Rune *r, i
|
||||||
Font *def;
|
Font *def;
|
||||||
Subfont *sf;
|
Subfont *sf;
|
||||||
|
|
||||||
|
if(len < 0)
|
||||||
|
sysfatal("libdraw: _string len=%d", len);
|
||||||
|
|
||||||
if(s == nil){
|
if(s == nil){
|
||||||
s = "";
|
s = "";
|
||||||
sptr = nil;
|
sptr = nil;
|
||||||
|
|
|
@ -63,6 +63,9 @@ frdrawsel0(Frame *f, Point pt, ulong p0, ulong p1, Image *back, Image *text)
|
||||||
uint p;
|
uint p;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
|
if(p0 > p1)
|
||||||
|
sysfatal("libframe: frdrawsel0 p0=%lud > p1=%lud", p0, p1);
|
||||||
|
|
||||||
p = 0;
|
p = 0;
|
||||||
b = f->box;
|
b = f->box;
|
||||||
trim = 0;
|
trim = 0;
|
||||||
|
|
Loading…
Reference in a new issue