mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
This commit is contained in:
parent
bddc9fe22b
commit
eb6f3ead00
2 changed files with 5 additions and 2 deletions
|
|
@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n,
|
|||
/* got a match! */
|
||||
return i;
|
||||
/* miss: check if previous character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, s[i-1]))
|
||||
if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
|
||||
i = i - m;
|
||||
else
|
||||
i = i - skip;
|
||||
} else {
|
||||
/* skip: check if previous character is part of pattern */
|
||||
if (!STRINGLIB_BLOOM(mask, s[i-1]))
|
||||
if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
|
||||
i = i - m;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue