diff options
author | Jay Berkenbilt <ejb@ql.org> | 2018-02-16 23:25:27 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2018-02-19 03:06:27 +0100 |
commit | d0e99f195a987c483bbb6c5449cf39bee34e08a1 (patch) | |
tree | cead8acd60cd14fd5d904ed380c750540cb361f3 /libqpdf/QPDFTokenizer.cc | |
parent | c2e16827b69f3d3ac3721cfcd608b87f28e2a13f (diff) | |
download | qpdf-d0e99f195a987c483bbb6c5449cf39bee34e08a1.tar.zst |
More robust handling of type errors
Give objects descriptions and context so it is possible to issue
warnings instead of fatal errors for attempts to access objects of the
wrong type.
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r-- | libqpdf/QPDFTokenizer.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc index c3a017d0..95551e7c 100644 --- a/libqpdf/QPDFTokenizer.cc +++ b/libqpdf/QPDFTokenizer.cc @@ -640,7 +640,9 @@ QPDFTokenizer::readToken(PointerHolder<InputSource> input, presented_eof = true; if ((this->m->type == tt_eof) && (! this->m->allow_eof)) { - QTC::TC("qpdf", "QPDFTokenizer EOF when not allowed"); + // Nothing in the qpdf library calls readToken + // without allowEOF anymore, so this case is not + // exercised. this->m->type = tt_bad; this->m->error_message = "unexpected EOF"; offset = input->getLastOffset(); @@ -677,7 +679,10 @@ QPDFTokenizer::readToken(PointerHolder<InputSource> input, input->unreadCh(char_to_unread); } - input->setLastOffset(offset); + if (token.getType() != tt_eof) + { + input->setLastOffset(offset); + } if (token.getType() == tt_bad) { |