Check for boundary errors in [r]find -- find("x", "", 2) should return -1.

This commit is contained in:
Guido van Rossum 1998-03-24 04:19:22 +00:00
parent c8d36284f3
commit 031c6315e2

View 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)