Prevent infinite loop in readObject() function. Patch by dhudson1. Closes mstamy2/PyPDF2#184
This commit is contained in:
parent
7456f0acea
commit
48193975e5
|
@ -82,6 +82,10 @@ def readObject(stream, pdf):
|
|||
# comment
|
||||
while tok not in (b_('\r'), b_('\n')):
|
||||
tok = stream.read(1)
|
||||
# Prevents an infinite loop by raising an error if the stream is at
|
||||
# the EOF
|
||||
if len(tok) <= 0:
|
||||
raise PdfStreamError("File ended unexpectedly.")
|
||||
tok = readNonWhitespace(stream)
|
||||
stream.seek(-1, 1)
|
||||
return readObject(stream, pdf)
|
||||
|
|
Loading…
Reference in New Issue