summaryrefslogtreecommitdiffstats
path: root/generic/tkTextMark.c
diff options
context:
space:
mode:
authornijtmans@users.sourceforge.net <jan.nijtmans>2012-01-23 20:56:44 (GMT)
committernijtmans@users.sourceforge.net <jan.nijtmans>2012-01-23 20:56:44 (GMT)
commit84df438f093451ef1314886b07addc82186d49f7 (patch)
tree18179e4667f58a3f14a391eb2df4eb426be4ced6 /generic/tkTextMark.c
parente92b2272247eef29862d35f851bf1c51402918f6 (diff)
downloadtk-84df438f093451ef1314886b07addc82186d49f7.zip
tk-84df438f093451ef1314886b07addc82186d49f7.tar.gz
tk-84df438f093451ef1314886b07addc82186d49f7.tar.bz2
patch-3477449: segfault when mark out of -startline/-endline range
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 55edb46..0e51e33 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -402,6 +402,8 @@ TkTextMarkNameToIndex(
TkTextIndex *indexPtr) /* Index information gets stored here. */
{
TkTextSegment *segPtr;
+ TkTextIndex index;
+ int start, end;
if (textPtr == NULL) {
return TCL_ERROR;
@@ -420,6 +422,29 @@ TkTextMarkNameToIndex(
segPtr = (TkTextSegment *) 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;
}