diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2005-08-11 12:17:08 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2005-08-11 12:17:08 (GMT) |
commit | caf3d7dc0594cd7f8e917757cbd49c931414ef18 (patch) | |
tree | 6628dcb4bda2551aaf3158b37e00d36264d17744 /generic/tkCanvText.c | |
parent | 0c1c0c2dc87d2fb75c61c730f4064440a0f99ecc (diff) | |
download | tk-caf3d7dc0594cd7f8e917757cbd49c931414ef18.zip tk-caf3d7dc0594cd7f8e917757cbd49c931414ef18.tar.gz tk-caf3d7dc0594cd7f8e917757cbd49c931414ef18.tar.bz2 |
Fix [Bug 1252702]
Diffstat (limited to 'generic/tkCanvText.c')
-rw-r--r-- | generic/tkCanvText.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 99d8e30..d2c1bf8 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvText.c,v 1.15.2.1 2004/06/08 20:44:11 mdejong Exp $ + * RCS: @(#) $Id: tkCanvText.c,v 1.15.2.2 2005/08/11 12:17:09 dkf Exp $ */ #include <stdio.h> @@ -1247,27 +1247,25 @@ GetTextIndex(interp, canvas, itemPtr, obj, indexPtr) * index. */ { TextItem *textPtr = (TextItem *) itemPtr; - size_t length; - int c; + int c, length; TkCanvas *canvasPtr = (TkCanvas *) canvas; Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr; - char *string = Tcl_GetStringFromObj(obj, (int *) &length); + char *string = Tcl_GetStringFromObj(obj, &length); c = string[0]; - length = strlen(string); - if ((c == 'e') && (strncmp(string, "end", length) == 0)) { + if ((c == 'e') && (strncmp(string, "end", (unsigned) length) == 0)) { *indexPtr = textPtr->numChars; - } else if ((c == 'i') && (strncmp(string, "insert", length) == 0)) { + } else if ((c=='i') && (strncmp(string, "insert", (unsigned) length)==0)) { *indexPtr = textPtr->insertPos; - } else if ((c == 's') && (strncmp(string, "sel.first", length) == 0) + } else if ((c=='s') && (strncmp(string, "sel.first", (unsigned) length)==0) && (length >= 5)) { if (textInfoPtr->selItemPtr != itemPtr) { Tcl_SetResult(interp, "selection isn't in item", TCL_STATIC); return TCL_ERROR; } *indexPtr = textInfoPtr->selectFirst; - } else if ((c == 's') && (strncmp(string, "sel.last", length) == 0) + } else if ((c=='s') && (strncmp(string, "sel.last", (unsigned) length)==0) && (length >= 5)) { if (textInfoPtr->selItemPtr != itemPtr) { Tcl_SetResult(interp, "selection isn't in item", TCL_STATIC); |