Skip to content

Commit 54252e6

Browse files
fix: fatal errors on pdfs (#41)
* 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]>
1 parent 778b15c commit 54252e6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/v2/pdf_decoders/stream.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ namespace pdflib
319319
}
320320
else
321321
{
322-
LOG_S(FATAL) << "invoking 'Q' on empty stack!";
323-
throw std::logic_error(__FILE__);
322+
LOG_S(ERROR) << "invoking 'Q' on empty stack!";
323+
//throw std::logic_error(__FILE__);
324324
}
325325
}
326326

src/v2/pdf_resources/page_font/cmap.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,18 @@ namespace pdflib
365365
auto itr = src.begin();
366366
c = utf8::next(itr, src.end());
367367

368-
assert(itr==src.end());
368+
//assert(itr==src.end());
369369
}
370-
assert(csr_range.first<=c and c<=csr_range.second);
370+
//assert(csr_range.first<=c and c<=csr_range.second);
371371

372+
if(not (csr_range.first<=c and c<=csr_range.second))
373+
{
374+
LOG_S(ERROR) << c << " is going out of bounds: " << csr_range.first << "," << csr_range.second;
375+
}
376+
372377
if(_map.count(c)==1)
373378
{
374-
LOG_S(FATAL) << "overwriting number c=" << c;
379+
LOG_S(ERROR) << "overwriting number cmap[" << c << "]: " << _map.at(c) << " with " << tgt;
375380
}
376381

377382
_map[c] = tgt;

src/v2/qpdf/stream_decoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace pdflib
5252

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

5757
stream.clear();
5858

@@ -62,7 +62,7 @@ namespace pdflib
6262
}
6363
catch(std::exception& e)
6464
{
65-
LOG_S(FATAL) << e.what();
65+
LOG_S(ERROR) << "QPDF encountered error (" << e.what() << ") during decoding";
6666
}
6767

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

0 commit comments

Comments
 (0)