diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 13e3b02..09c5b6e 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -401,11 +401,17 @@ void PDFDoc::checkHeader() { char *p; char *tokptr; int i; + int c; pdfMajorVersion = 0; pdfMinorVersion = 0; for (i = 0; i < headerSearchSize; ++i) { - hdrBuf[i] = str->getChar(); + if ((c = str->getChar()) == EOF) + { + error(errSyntaxWarning, -1, "EOF while reading header (continuing anyway)"); + return; + } + hdrBuf[i] = c; } hdrBuf[headerSearchSize] = '\0'; for (i = 0; i < headerSearchSize - 5; ++i) {