From 2c2c75c017b5d8c3ce7f6b06e4b5fc3a5dc92fde Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 18 Jun 2011 23:48:13 +0200 Subject: [PATCH] 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. --- history.c | 2 +- xhistory.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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); -- 1.7.0.4