Add a safety limit to the number of unicode characters we fetch

(followup to r84635, suggested by Dave Malcolm).
This commit is contained in:
Antoine Pitrou 2010-09-08 21:07:40 +00:00
parent b41e128fe1
commit b1856d7fa7
1 changed files with 2 additions and 1 deletions

View File

@ -1103,7 +1103,8 @@ class PyUnicodeObjectPtr(PyObjectPtr):
# inferior process: we must join surrogate pairs.
Py_UNICODEs = []
i = 0
while i < field_length:
limit = safety_limit(field_length)
while i < limit:
ucs = int(field_str[i])
i += 1
if ucs < 0xD800 or ucs >= 0xDC00 or i == field_length: