summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 22:07:16 +0000
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-08-08 22:07:16 +0000
commitf445cdca00f3dec33ebcf41f25a59afa113470f3 (patch)
tree559822d94b63488d5983b0cff025b3446fa6f79f
parent9847d74fb7da263e9d1943d6c635656d54f44de6 (diff)
downloadcpython-f445cdca00f3dec33ebcf41f25a59afa113470f3.tar.gz
Fix #8530: Prevent stringlib fastsearch from reading beyond the front of an array.
-rw-r--r--Misc/NEWS3
-rw-r--r--Objects/stringlib/fastsearch.h4
2 files changed, 5 insertions, 2 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 9f3d80a63d..7aba37d83e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@ What's New in Python 3.2 Alpha 2?
Core and Builtins
-----------------
+- Issue #8530: Prevent stringlib fastsearch from reading beyond the front
+ of an array.
+
- Issue #5319: Print an error if flushing stdout fails at interpreter
shutdown.
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
index 7525951c06..e231c587e4 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;
}
}