From 9c07345842ef2fdcdd7ddc161e3b9b15e77e23a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= Date: Fri, 16 Aug 2013 15:00:24 +0200 Subject: [PATCH] Prevent infinite loop when input file is empty --- PyPDF2/pdf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index 02804fba1..6deda0ed1 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -958,6 +958,9 @@ def read(self, stream): if debug: print ">>read", stream # start at the end: stream.seek(-1, 2) + if not stream.tell(): + raise utils.PdfReadError, "File is empty" + line = b_('') if debug: print " line:",line while not line: