summaryrefslogtreecommitdiffstats
path: root/generic/tkTextMark.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-01-25 21:14:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-01-25 21:14:19 (GMT)
commit3584b89a6de6f3cd5937ffd105586b02bae1b75c (patch)
treee9665bba1fa5305a3954ad06939ee5bd49afcc16 /generic/tkTextMark.c
parent46f8e6a42f733757291f1cdca45e2f0d36ce353f (diff)
parent6dc4d17c33afcfb61b3d875a779f5fbe3f01624f (diff)
downloadtk-3584b89a6de6f3cd5937ffd105586b02bae1b75c.zip
tk-3584b89a6de6f3cd5937ffd105586b02bae1b75c.tar.gz
tk-3584b89a6de6f3cd5937ffd105586b02bae1b75c.tar.bz2
[Bug-1630271]: segfault/infinite loop when a mark is before -startline
Diffstat (limited to 'generic/tkTextMark.c')
-rw-r--r--generic/tkTextMark.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index 6117127..026ca33 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -403,6 +403,8 @@ TkTextMarkNameToIndex(
TkTextIndex *indexPtr) /* Index information gets stored here. */
{
TkTextSegment *segPtr;
+ TkTextIndex index;
+ int start, end;
if (textPtr == NULL) {
return TCL_ERROR;
@@ -422,6 +424,29 @@ TkTextMarkNameToIndex(
segPtr = Tcl_GetHashValue(hPtr);
}
TkTextMarkSegToIndex(textPtr, segPtr, indexPtr);
+
+ /* If indexPtr refers to somewhere outside the -startline/-endline
+ * range limits of the widget, error out since the mark indeed is not
+ * reachable from this text widget (it may be reachable from a peer)
+ * (bug 1630271).
+ */
+
+ if (textPtr->start != NULL) {
+ start = TkBTreeLinesTo(NULL, textPtr->start);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, start, 0,
+ &index);
+ if (TkTextIndexCmp(indexPtr, &index) < 0) {
+ return TCL_ERROR;
+ }
+ }
+ if (textPtr->end != NULL) {
+ end = TkBTreeLinesTo(NULL, textPtr->end);
+ TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, NULL, end, 0,
+ &index);
+ if (TkTextIndexCmp(indexPtr, &index) > 0) {
+ return TCL_ERROR;
+ }
+ }
return TCL_OK;
}