diff --git a/libqpdf/Pl_QPDFTokenizer.cc b/libqpdf/Pl_QPDFTokenizer.cc index 7bb86d5f..91973fc4 100644 --- a/libqpdf/Pl_QPDFTokenizer.cc +++ b/libqpdf/Pl_QPDFTokenizer.cc @@ -36,20 +36,17 @@ void Pl_QPDFTokenizer::finish() { m->buf.finish(); - auto input = std::shared_ptr( - // line-break - new BufferInputSource("tokenizer data", m->buf.getBuffer(), true)); - + auto input = BufferInputSource("tokenizer data", m->buf.getBuffer(), true); + std::string empty; while (true) { - QPDFTokenizer::Token token = - m->tokenizer.readToken(input, "offset " + std::to_string(input->tell()), true); + auto token = m->tokenizer.readToken(input, empty, true); m->filter->handleToken(token); if (token.getType() == QPDFTokenizer::tt_eof) { break; } else if (token.isWord("ID")) { // Read the space after the ID. char ch = ' '; - input->read(&ch, 1); + input.read(&ch, 1); m->filter->handleToken( // line-break QPDFTokenizer::Token(QPDFTokenizer::tt_space, std::string(1, ch))); diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index 9b789883..d48abd3e 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -904,7 +904,7 @@ QPDFTokenizer::readToken( throw QPDFExc( qpdf_e_damaged_pdf, input.getName(), - context, + context.empty() ? "offset " + std::to_string(input.getLastOffset()) : context, input.getLastOffset(), token.getErrorMessage()); }