summaryrefslogtreecommitdiff
path: root/Objects/stringlib/fastsearch.h
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-09-20 20:56:47 +0200
committerAntoine Pitrou <solipsis@pitrou.net>2012-09-20 20:56:47 +0200
commitca8aa4acf6755dd012706e1e38fb737ae83ab5c6 (patch)
tree310b20a536a99dd80657e2d22e07bb1466d0a895 /Objects/stringlib/fastsearch.h
parent1c47222a256f2977dcbb36c05dce7a5ae8e6ae06 (diff)
downloadcpython-git-ca8aa4acf6755dd012706e1e38fb737ae83ab5c6.tar.gz
Issue #15144: Fix possible integer overflow when handling pointers as integer values, by using Py_uintptr_t instead of size_t.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Objects/stringlib/fastsearch.h')
-rw-r--r--Objects/stringlib/fastsearch.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/Objects/stringlib/fastsearch.h b/Objects/stringlib/fastsearch.h
index 5b8d5dbcdd..ecf885e7e1 100644
--- a/Objects/stringlib/fastsearch.h
+++ b/Objects/stringlib/fastsearch.h
@@ -43,8 +43,7 @@ STRINGLIB(fastsearch_memchr_1char)(const STRINGLIB_CHAR* s, Py_ssize_t n,
#define DO_MEMCHR(memchr, s, needle, nchars) do { \
candidate = memchr((const void *) (s), (needle), (nchars) * sizeof(STRINGLIB_CHAR)); \
- found = (const STRINGLIB_CHAR *) \
- ((Py_ssize_t) candidate & (~ ((Py_ssize_t) sizeof(STRINGLIB_CHAR) - 1))); \
+ found = (const STRINGLIB_CHAR *) _Py_ALIGN_DOWN(candidate, sizeof(STRINGLIB_CHAR)); \
} while (0)
if (mode == FAST_SEARCH) {