Skip to content

Commit 031c631

Browse files
committed
Check for boundary errors in [r]find -- find("x", "", 2) should return -1.
1 parent c8d3628 commit 031c631

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎Modules/stropmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ strop_find(self, args)
349349
if (i < 0)
350350
i = 0;
351351

352-
if (n == 0)
352+
if (n == 0 && i <= last)
353353
return PyInt_FromLong((long)i);
354354

355355
last -= n;
@@ -394,7 +394,7 @@ strop_rfind(self, args)
394394
if (i < 0)
395395
i = 0;
396396

397-
if (n == 0)
397+
if (n == 0 && i <= last)
398398
return PyInt_FromLong((long)last);
399399

400400
for (j = last-n; j >= i; --j)

0 commit comments

Comments
 (0)