Commit be27d47bdc1195f425821d479b9ca733051343c0
1 parent
48864b8d
Use better error for getStreamData failure
If the stream isn't filterable but we call getStreamData, throw a regular exception instead of a logic error so that normal error handling and reporting mechanisms will be used.
Showing
2 changed files
with
7 additions
and
2 deletions
libqpdf/QPDF_Stream.cc
| @@ -96,7 +96,9 @@ QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level) | @@ -96,7 +96,9 @@ QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level) | ||
| 96 | Pl_Buffer buf("stream data buffer"); | 96 | Pl_Buffer buf("stream data buffer"); |
| 97 | if (! pipeStreamData(&buf, 0, decode_level, false, false)) | 97 | if (! pipeStreamData(&buf, 0, decode_level, false, false)) |
| 98 | { | 98 | { |
| 99 | - throw std::logic_error("getStreamData called on unfilterable stream"); | 99 | + throw QPDFExc(qpdf_e_unsupported, qpdf->getFilename(), |
| 100 | + "", this->offset, | ||
| 101 | + "getStreamData called on unfilterable stream"); | ||
| 100 | } | 102 | } |
| 101 | QTC::TC("qpdf", "QPDF_Stream getStreamData"); | 103 | QTC::TC("qpdf", "QPDF_Stream getStreamData"); |
| 102 | return buf.getBuffer(); | 104 | return buf.getBuffer(); |
qpdf/qtest/qpdf/issue-148.out
| @@ -4,4 +4,7 @@ WARNING: issue-148.pdf (xref stream: object 8 0, file position 73): attempting t | @@ -4,4 +4,7 @@ WARNING: issue-148.pdf (xref stream: object 8 0, file position 73): attempting t | ||
| 4 | WARNING: issue-148.pdf (xref stream: object 8 0, file position 73): recovered stream length: 2 | 4 | WARNING: issue-148.pdf (xref stream: object 8 0, file position 73): recovered stream length: 2 |
| 5 | WARNING: issue-148.pdf (xref stream: object 8 0, file position 85): expected endobj | 5 | WARNING: issue-148.pdf (xref stream: object 8 0, file position 85): expected endobj |
| 6 | WARNING: issue-148.pdf (file position 73): error decoding stream data for object 8 0: stream inflate: inflate: data: incorrect header check | 6 | WARNING: issue-148.pdf (file position 73): error decoding stream data for object 8 0: stream inflate: inflate: data: incorrect header check |
| 7 | -getStreamData called on unfilterable stream | 7 | +WARNING: issue-148.pdf: file is damaged |
| 8 | +WARNING: issue-148.pdf (file position 73): getStreamData called on unfilterable stream | ||
| 9 | +WARNING: issue-148.pdf: Attempting to reconstruct cross-reference table | ||
| 10 | +issue-148.pdf: unable to find trailer dictionary while recovering damaged file |