summaryrefslogtreecommitdiffstats
path: root/Objects/stringlib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 22:07:16 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 22:07:16 (GMT)
commiteb6f3ead00f1cccffafba03245861a4d6bd84346 (patch)
treeae40df9ad342570b5e149d4afeddc8a0e34fd284 /Objects/stringlib
parentbddc9fe22bb5d78bfb3db891d3b2d56d963f6e04 (diff)
downloadcpython-eb6f3ead00f1cccffafba03245861a4d6bd84346.zip
cpython-eb6f3ead00f1cccffafba03245861a4d6bd84346.tar.gz
cpython-eb6f3ead00f1cccffafba03245861a4d6bd84346.tar.bz2
Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
Diffstat (limited to 'Objects/stringlib')
-rw-r--r--Objects/stringlib/fastsearch.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
index 7525951..e231c58 100644
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -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;
}
}