Skip to content

Commit eb6f3ea

Browse files
committed
Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
1 parent bddc9fe commit eb6f3ea

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 2?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #8530: Prevent stringlib fastsearch from reading beyond the front
16+
of an array.
17+
1518
- Issue #5319: Print an error if flushing stdout fails at interpreter
1619
shutdown.
1720

Objects/stringlib/fastsearch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ fastsearch(const STRINGLIB_CHAR* s, Py_ssize_t n,
140140
/* got a match! */
141141
return i;
142142
/* miss: check if previous character is part of pattern */
143-
if (!STRINGLIB_BLOOM(mask, s[i-1]))
143+
if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
144144
i = i - m;
145145
else
146146
i = i - skip;
147147
} else {
148148
/* skip: check if previous character is part of pattern */
149-
if (!STRINGLIB_BLOOM(mask, s[i-1]))
149+
if (i > 0 && !STRINGLIB_BLOOM(mask, s[i-1]))
150150
i = i - m;
151151
}
152152
}

0 commit comments

Comments
 (0)