Mercurial > cpython-lru_cache-weakref
diff Objects/stringobject.c @ 84540:2921f6c2009e 2.7
Issue #18427: str.replace could crash the interpreter with huge strings.
This fixes two places where 'int' was used to represent
the size of strings, instead of 'Py_ssize_t'.
(The issue is not present in the corresponding code in the 3.x branches)
Fixes #18427
| author | Ronald Oussoren <ronaldoussoren@mac.com> |
|---|---|
| date | Thu, 11 Jul 2013 13:33:55 +0200 |
| parents | 391e3a7db1a3 |
| children | ac2f59a6637f |
line wrap: on
line diff
--- a/Objects/stringobject.c Wed Jul 10 16:23:15 2013 -0400 +++ b/Objects/stringobject.c Thu Jul 11 13:33:55 2013 +0200 @@ -882,9 +882,9 @@ size -= chunk_size; } #ifdef __VMS - if (size) fwrite(data, (int)size, 1, fp); + if (size) fwrite(data, (size_t)size, 1, fp); #else - fwrite(data, 1, (int)size, fp); + fwrite(data, 1, (size_t)size, fp); #endif Py_END_ALLOW_THREADS return 0; @@ -2332,7 +2332,7 @@ } Py_LOCAL_INLINE(Py_ssize_t) -countchar(const char *target, int target_len, char c, Py_ssize_t maxcount) +countchar(const char *target, Py_ssize_t target_len, char c, Py_ssize_t maxcount) { Py_ssize_t count=0; const char *start=target;
