summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-03-24 04:19:22 (GMT)
committerGuido van Rossum <guido@python.org>1998-03-24 04:19:22 (GMT)
commit031c6315e23d41e253c914eceffd30afe8a0f2cd (patch)
tree2b78c30a95d93e269c5da05236d372592b586fbb
parentc8d36284f3456af9991df6f225f6dc1af742aa3a (diff)
downloadcpython-031c6315e23d41e253c914eceffd30afe8a0f2cd.zip
cpython-031c6315e23d41e253c914eceffd30afe8a0f2cd.tar.gz
cpython-031c6315e23d41e253c914eceffd30afe8a0f2cd.tar.bz2
Check for boundary errors in [r]find -- find("x", "", 2) should return -1.
-rw-r--r--Modules/stropmodule.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c
index 1821db8..e9e9039 100644
--- a/Modules/stropmodule.c
+++ b/Modules/stropmodule.c
@@ -349,7 +349,7 @@ strop_find(self, args)
if (i < 0)
i = 0;
- if (n == 0)
+ if (n == 0 && i <= last)
return PyInt_FromLong((long)i);
last -= n;
@@ -394,7 +394,7 @@ strop_rfind(self, args)
if (i < 0)
i = 0;
- if (n == 0)
+ if (n == 0 && i <= last)
return PyInt_FromLong((long)last);
for (j = last-n; j >= i; --j)