]> granicus.if.org Git - python/commitdiff
Check for boundary errors in [r]find -- find("x", "", 2) should return -1.
authorGuido van Rossum <guido@python.org>
Tue, 24 Mar 1998 04:19:22 +0000 (04:19 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 24 Mar 1998 04:19:22 +0000 (04:19 +0000)
Modules/stropmodule.c

index 1821db84a64f5b15eed095c15724af94937c4341..e9e9039397fa96ed8b903201c42668071e3cb64f 100644 (file)
@@ -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)