Commit d9ae41b0574f16298c019c64665f48a287d37a2d

Authored by m-holger
1 parent 9cdf980f

Fix /DecodeParms handling logic inconsistency

Moved the conditional check for /DecodeParms inconsistency into the loop to ensure clearer handling when filters are non-empty. This improves code structure and maintains robustness for edge cases encountered in the wild.
Showing 1 changed file with 6 additions and 7 deletions
libqpdf/QPDF_Stream.cc
... ... @@ -399,13 +399,12 @@ Stream::filterable(
399 399 for (auto& item: decode_array) {
400 400 decode_parms.emplace_back(item);
401 401 }
402   - }
403   -
404   - // Ignore /DecodeParms entirely if /Filters is empty. At least one case of a file whose
405   - // /DecodeParms was [ << >> ] when /Filters was empty has been seen in the wild.
406   - if ((filters.size() != 0) && (decode_parms.size() != filters.size())) {
407   - warn("stream /DecodeParms length is inconsistent with filters");
408   - return false;
  402 + // Ignore /DecodeParms entirely if /Filters is empty. At least one case of a file whose
  403 + // /DecodeParms was [ << >> ] when /Filters was empty has been seen in the wild.
  404 + if (!filters.empty() && decode_parms.size() != filters.size()) {
  405 + warn("stream /DecodeParms length is inconsistent with filters");
  406 + return false;
  407 + }
409 408 }
410 409  
411 410 for (size_t i = 0; i < filters.size(); ++i) {
... ...