Document default type value in CPDF_Parser::ProcessCrossRefV5Entry()
Reference the PDF spec and explain why the default object type in
CPDF_Parser::ProcessCrossRefV5Entry() is set as such.
Change-Id: Ie11f1053f6092a39accc52a5e64ee953207fa454
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/108770
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Nigi <nigi@chromium.org>
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 39324f2..b1f591d 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -839,13 +839,18 @@
pdfium::span<const uint32_t> field_widths,
uint32_t obj_num) {
DCHECK_GE(field_widths.size(), kMinFieldCount);
- ObjectType type = ObjectType::kNotCompressed;
+ ObjectType type;
if (field_widths[0]) {
const uint32_t cross_ref_stream_obj_type =
GetFirstXRefStreamEntry(entry_span, field_widths);
type = GetObjectTypeFromCrossRefStreamType(cross_ref_stream_obj_type);
if (type == ObjectType::kNull)
return;
+ } else {
+ // Per ISO 32000-1:2008 table 17, use the default value of 1 for the xref
+ // stream entry when it is not specified. The `type` assignment is the
+ // equivalent to calling GetObjectTypeFromCrossRefStreamType(1).
+ type = ObjectType::kNotCompressed;
}
const ObjectType existing_type = GetObjectType(obj_num);