summaryrefslogtreecommitdiffstats
path: root/generic/tclCmdMZ.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclCmdMZ.c')
-rw-r--r--generic/tclCmdMZ.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 1ff2138..70002b5 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -15,7 +15,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.163.2.5 2009/08/25 21:01:05 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclCmdMZ.c,v 1.163.2.6 2010/02/27 21:25:05 dkf Exp $
*/
#include "tclInt.h"
@@ -1166,7 +1166,12 @@ StringFirstCmd(
}
}
- if (length1 > 0) {
+ /*
+ * If the length of the needle is more than the length of the haystack, it
+ * cannot be contained in there so we can avoid searching. [Bug 2960021]
+ */
+
+ if (length1 > 0 && length1 <= length2) {
register Tcl_UniChar *p, *end;
end = ustring2 + length2 - length1 + 1;
@@ -1269,7 +1274,12 @@ StringLastCmd(
p = ustring2 + length2 - length1;
}
- if (length1 > 0) {
+ /*
+ * If the length of the needle is more than the length of the haystack, it
+ * cannot be contained in there so we can avoid searching. [Bug 2960021]
+ */
+
+ if (length1 > 0 && length1 <= length2) {
for (; p >= ustring2; p--) {
/*
* Scan backwards to find the first character.