diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-08-01 15:25:13 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-01 22:41:02 +0000 |
commit | 07a71da70e7d52dbc65cd184edec3c45e1e8567e (patch) | |
tree | 0a06bdd7ca2fb868ff77bd25ba35b1c9bb5bd29d /core/fpdfapi | |
parent | 7d8544ad898255fc4dffab0a36c6cb69fce421a1 (diff) | |
download | pdfium-07a71da70e7d52dbc65cd184edec3c45e1e8567e.tar.xz |
Improve readability in CPDF_Parser::ObjectInfo.
Make CPDF_Parser::ObjectInfo::pos a union, since the data is used as an
object number when the object is compressed.
Change-Id: Id7c32759f7411cc80285bb7f3088b5aa6ff5bf05
Reviewed-on: https://pdfium-review.googlesource.com/9570
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.cpp | 19 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_parser.h | 9 |
2 files changed, 19 insertions, 9 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp index eb59195aa2..657d0e0865 100644 --- a/core/fpdfapi/parser/cpdf_parser.cpp +++ b/core/fpdfapi/parser/cpdf_parser.cpp @@ -1068,19 +1068,24 @@ bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) { if (GetObjectType(startnum + j) != ObjectType::kFree) continue; - m_ObjectInfo[startnum + j].type = type; + ObjectInfo& info = m_ObjectInfo[startnum + j]; + + info.type = type; if (type == ObjectType::kFree) { - m_ObjectInfo[startnum + j].pos = 0; + info.pos = 0; } else { - FX_FILESIZE offset = + const FX_FILESIZE entry_value = GetVarInt(entrystart + WidthArray[0], WidthArray[1]); - m_ObjectInfo[startnum + j].pos = offset; if (type == ObjectType::kNotCompressed) { - m_SortedOffset.insert(offset); + const auto object_offset = entry_value; + m_SortedOffset.insert(object_offset); + info.pos = object_offset; } else { - if (offset < 0 || !IsValidObjectNumber(offset)) + const auto archive_obj_num = entry_value; + info.archive_obj_num = archive_obj_num; + if (archive_obj_num < 0 || !IsValidObjectNumber(archive_obj_num)) return false; - m_ObjectInfo[offset].type = ObjectType::kNull; + m_ObjectInfo[archive_obj_num].type = ObjectType::kNull; } } } diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h index 4d78d7052f..ece1e6a2d4 100644 --- a/core/fpdfapi/parser/cpdf_parser.h +++ b/core/fpdfapi/parser/cpdf_parser.h @@ -111,8 +111,13 @@ class CPDF_Parser { protected: struct ObjectInfo { ObjectInfo() : pos(0), type(ObjectType::kFree), gennum(0) {} - - FX_FILESIZE pos; + // if type is ObjectType::kCompressed the archive_obj_num should be used. + // if type is ObjectType::kNotCompressed the pos should be used. + // In other cases its are unused. + union { + FX_FILESIZE pos; + FX_FILESIZE archive_obj_num; + }; ObjectType type; uint16_t gennum; }; |