From: H.G. Muller Date: Sat, 18 Jun 2011 21:48:13 +0000 (+0200) Subject: Fix crash on clearing new Move List window X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=2c2c75c017b5d8c3ce7f6b06e4b5fc3a5dc92fde;p=xboard.git Fix crash on clearing new Move List window When a new game started and a previous game had filled the Move List window, a crash occurred because an attempt was made to undo the highlighting of a no-longer-existing move, and then scrolling to it. --- diff --git a/history.c b/history.c index 6773133..503f6a0 100644 --- a/history.c +++ b/history.c @@ -174,7 +174,7 @@ void MemoContentUpdated() { int caretPos; - DoHighlight( lastCurrent, FALSE ); + if(lastCurrent <= currLast) DoHighlight( lastCurrent, FALSE ); DoHighlight( currCurrent, TRUE ); lastFirst = currFirst; diff --git a/xhistory.c b/xhistory.c index 919ea9a..7dc3c9f 100644 --- a/xhistory.c +++ b/xhistory.c @@ -101,7 +101,7 @@ void ScrollToCurrent(int caretPos) Arg args[10]; char *s; GetWidgetText(&historyOptions[0], &s); - if(caretPos < 0) caretPos = strlen(s); + if(caretPos < 0 || caretPos > strlen(s)) caretPos = strlen(s); XtSetArg(args[0], XtNdisplayCaret, False); XtSetArg(args[1], XtNinsertPosition, caretPos); // this triggers scrolling in Xaw XtSetValues(historyOptions[0].handle, args, 2);