Skip to content

Commit

Permalink
fix: fatal errors on pdfs (#41)
Browse files Browse the repository at this point in the history
* fix: replaced fatal with error message

Signed-off-by: Peter Staar <[email protected]>

* become more lenient with qpdf decoding errors

Signed-off-by: Peter Staar <[email protected]>

---------

Signed-off-by: Peter Staar <[email protected]>
  • Loading branch information
PeterStaar-IBM authored Oct 18, 2024
1 parent 778b15c commit 54252e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/v2/pdf_decoders/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ namespace pdflib
}
else
{
LOG_S(FATAL) << "invoking 'Q' on empty stack!";
throw std::logic_error(__FILE__);
LOG_S(ERROR) << "invoking 'Q' on empty stack!";
//throw std::logic_error(__FILE__);
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/v2/pdf_resources/page_font/cmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,18 @@ namespace pdflib
auto itr = src.begin();
c = utf8::next(itr, src.end());

assert(itr==src.end());
//assert(itr==src.end());
}
assert(csr_range.first<=c and c<=csr_range.second);
//assert(csr_range.first<=c and c<=csr_range.second);

if(not (csr_range.first<=c and c<=csr_range.second))
{
LOG_S(ERROR) << c << " is going out of bounds: " << csr_range.first << "," << csr_range.second;
}

if(_map.count(c)==1)
{
LOG_S(FATAL) << "overwriting number c=" << c;
LOG_S(ERROR) << "overwriting number cmap[" << c << "]: " << _map.at(c) << " with " << tgt;
}

_map[c] = tgt;
Expand Down
4 changes: 2 additions & 2 deletions src/v2/qpdf/stream_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace pdflib

void qpdf_stream_decoder::decode(QPDFObjectHandle& content)
{
LOG_S(WARNING) << "start decoding content-stream: " << content.getTypeName() << " -> " << content.unparse();
LOG_S(INFO) << "start decoding content-stream: " << content.getTypeName() << " -> " << content.unparse();

stream.clear();

Expand All @@ -62,7 +62,7 @@ namespace pdflib
}
catch(std::exception& e)
{
LOG_S(FATAL) << e.what();
LOG_S(ERROR) << "QPDF encountered error (" << e.what() << ") during decoding";
}

LOG_S(WARNING) << "finished decoding content-stream!";
Expand Down

0 comments on commit 54252e6

Please sign in to comment.