pypdf icon indicating copy to clipboard operation
pypdf copied to clipboard

Infinite loop with PDFFileReader when file is empty

Open jerome-nexedi opened this issue 13 years ago • 3 comments

Reproducible with:

import StringIO, PyPDF2

PyPDF2.PdfFileReader(StringIO.StringIO())

jerome-nexedi avatar Aug 16 '13 13:08 jerome-nexedi

The infinite loop bug occurs in the ReadNextEndLine() method. We'll include a fix in the next patch - would it be acceptable to just throw an exception?

mstamy2 avatar Aug 16 '13 21:08 mstamy2

Added the fix for infinite loop caused by empty file just now - however I recently noticed that a StringIO object with random characters with cause an infinite loop as well instead of throwing an exception. We should be able to fix this easily.

mstamy2 avatar Aug 19 '13 19:08 mstamy2

This was solved pre 1.20, so I'll ignore it. I hope nobody still uses such an old version

MartinThoma avatar Jun 30 '23 15:06 MartinThoma