diff options
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r-- | generic/tclCmdMZ.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index 45a2bed..c61afc5 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.16 2005/04/22 16:30:02 dgp Exp $ + * RCS: @(#) $Id: tclCmdMZ.c,v 1.82.2.17 2005/05/11 00:48:01 hobbs Exp $ */ #include "tclInt.h" @@ -1936,7 +1936,8 @@ Tcl_StringObjCmd(dummy, interp, objc, objv) ustring2 = Tcl_GetUnicodeFromObj(mapElemv[0], &length2); p = ustring1; - if (length2 == 0) { + if ((length2 > length1) || (length2 == 0)) { + /* match string is either longer than input or empty */ ustring1 = end; } else { mapString = Tcl_GetUnicodeFromObj(mapElemv[1], &mapLen); @@ -1994,6 +1995,8 @@ Tcl_StringObjCmd(dummy, interp, objc, objv) if ((length2 > 0) && ((*ustring1 == *ustring2) || (nocase && (Tcl_UniCharToLower(*ustring1) == u2lc[index/2]))) && + /* restrict max compare length */ + ((end - ustring1) >= length2) && ((length2 == 1) || strCmpFn(ustring2, ustring1, (unsigned long) length2) == 0)) { if (p != ustring1) { |