Commit 60c7d594b835ae2eac8235658179aedce7b3b007
1 parent
972cbf10
In QPDF::filterCompressedObjects ignore objects not in QPDFWriter tables
Add fuzz case 68377.
Showing
5 changed files
with
22 additions
and
11 deletions
fuzz/CMakeLists.txt
fuzz/qpdf_extra/68377.fuzz
0 → 100644
No preview for this file type
fuzz/qtest/fuzz.test
libqpdf/QPDF_optimization.cc
| ... | ... | @@ -416,22 +416,26 @@ QPDF::filterCompressedObjects(QPDFWriter::ObjTable const& obj) |
| 416 | 416 | ObjUser const& ou = i1.first; |
| 417 | 417 | // Loop over objects. |
| 418 | 418 | for (auto const& og: i1.second) { |
| 419 | - if (auto const& i2 = obj[og].object_stream; i2 <= 0) { | |
| 420 | - t_obj_user_to_objects[ou].insert(og); | |
| 421 | - } else { | |
| 422 | - t_obj_user_to_objects[ou].insert(QPDFObjGen(i2, 0)); | |
| 419 | + if (obj.contains(og)) { | |
| 420 | + if (auto const& i2 = obj[og].object_stream; i2 <= 0) { | |
| 421 | + t_obj_user_to_objects[ou].insert(og); | |
| 422 | + } else { | |
| 423 | + t_obj_user_to_objects[ou].insert(QPDFObjGen(i2, 0)); | |
| 424 | + } | |
| 423 | 425 | } |
| 424 | 426 | } |
| 425 | 427 | } |
| 426 | 428 | |
| 427 | 429 | for (auto const& i1: m->object_to_obj_users) { |
| 428 | 430 | QPDFObjGen const& og = i1.first; |
| 429 | - // Loop over obj_users. | |
| 430 | - for (auto const& ou: i1.second) { | |
| 431 | - if (auto i2 = obj[og].object_stream; i2 <= 0) { | |
| 432 | - t_object_to_obj_users[og].insert(ou); | |
| 433 | - } else { | |
| 434 | - t_object_to_obj_users[QPDFObjGen(i2, 0)].insert(ou); | |
| 431 | + if (obj.contains(og)) { | |
| 432 | + // Loop over obj_users. | |
| 433 | + for (auto const& ou: i1.second) { | |
| 434 | + if (auto i2 = obj[og].object_stream; i2 <= 0) { | |
| 435 | + t_object_to_obj_users[og].insert(ou); | |
| 436 | + } else { | |
| 437 | + t_object_to_obj_users[QPDFObjGen(i2, 0)].insert(ou); | |
| 438 | + } | |
| 435 | 439 | } |
| 436 | 440 | } |
| 437 | 441 | } | ... | ... |
libqpdf/qpdf/ObjTable.hh
| ... | ... | @@ -63,6 +63,12 @@ class ObjTable: public std::vector<T> |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | inline bool |
| 66 | + contains(QPDFObjGen og) const | |
| 67 | + { | |
| 68 | + return contains(static_cast<size_t>(og.getObj())); | |
| 69 | + } | |
| 70 | + | |
| 71 | + inline bool | |
| 66 | 72 | contains(QPDFObjectHandle oh) const |
| 67 | 73 | { |
| 68 | 74 | return contains(static_cast<size_t>(oh.getObjectID())); | ... | ... |