summaryrefslogtreecommitdiffstats
path: root/generic/tkText.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-01-25 21:13:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-01-25 21:13:39 (GMT)
commit6dc4d17c33afcfb61b3d875a779f5fbe3f01624f (patch)
treeeecb0149dc58d041678d5df28192820f1ff55ae1 /generic/tkText.c
parent27cdbeeb3a3582ec447eecaf0963a22790a4e418 (diff)
parent11055b075cd7483e19d76b5b7c070afd12167f94 (diff)
downloadtk-6dc4d17c33afcfb61b3d875a779f5fbe3f01624f.zip
tk-6dc4d17c33afcfb61b3d875a779f5fbe3f01624f.tar.gz
tk-6dc4d17c33afcfb61b3d875a779f5fbe3f01624f.tar.bz2
[Bug-1630271]: segfault/infinite loop when a mark is before -startline
Diffstat (limited to 'generic/tkText.c')
-rw-r--r--generic/tkText.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/generic/tkText.c b/generic/tkText.c
index 6b42489..76051da 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -2022,6 +2022,7 @@ ConfigureText(
if (mask & TK_TEXT_LINE_RANGE) {
int start, end, current;
+ TkTextIndex index1, index2, index3;
/*
* Line start and/or end have been adjusted. We need to validate the
@@ -2048,13 +2049,15 @@ ConfigureText(
return TCL_ERROR;
}
current = TkBTreeLinesTo(NULL, textPtr->topIndex.linePtr);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
+ &index1);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0,
+ &index2);
if (current < start || current > end) {
TkTextSearch search;
- TkTextIndex index1, first, last;
+ TkTextIndex first, last;
int selChanged = 0;
- TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
- &index1);
TkTextSetYView(textPtr, &index1, 0);
/*
@@ -2098,6 +2101,29 @@ ConfigureText(
textPtr->abortSelections = 1;
}
}
+
+ /* Indices are potentially obsolete after changing -startline and/or
+ * -endline, therefore increase the epoch.
+ * Also, clamp the insert and current (unshared) marks to the new
+ * -startline/-endline range limits of the widget. All other (shared)
+ * marks are unchanged.
+ */
+
+ textPtr->sharedTextPtr->stateEpoch++;
+ TkTextMarkNameToIndex(textPtr, "insert", &index3);
+ if (TkTextIndexCmp(&index3, &index1) < 0) {
+ textPtr->insertMarkPtr = TkTextSetMark(textPtr, "insert", &index1);
+ }
+ if (TkTextIndexCmp(&index3, &index2) > 0) {
+ textPtr->insertMarkPtr = TkTextSetMark(textPtr, "insert", &index2);
+ }
+ TkTextMarkNameToIndex(textPtr, "current", &index3);
+ if (TkTextIndexCmp(&index3, &index1) < 0) {
+ textPtr->currentMarkPtr = TkTextSetMark(textPtr, "current", &index1);
+ }
+ if (TkTextIndexCmp(&index3, &index2) > 0) {
+ textPtr->currentMarkPtr = TkTextSetMark(textPtr, "current", &index2);
+ }
textPtr->sharedTextPtr->stateEpoch++;
}