summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-08-29 13:08:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-29 13:08:25 -0700
commitc116e597ef4dfac88248d6de0e7c9bdf093b6e7c (patch)
tree94d75c895e6ad0a68ba000393e1e4251d93428f7
parent91ddd3f7501429222f648b986a99f3959a398889 (diff)
downloadpdfium-c116e597ef4dfac88248d6de0e7c9bdf093b6e7c.tar.xz
Verify element exists before accessing.
Currently when the parser utility classes are outputting to a text buffer we do not verify that an element from an array exists before accessing. We can have null items in arrays (and dictionaries but the dictionary case is already handled). This Cl updates the code to check the element exists before attempting to use the element. BUG=chromium:641076 Review-Url: https://codereview.chromium.org/2292473004
-rw-r--r--core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index a738356e43..6b1958298c 100644
--- a/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -179,7 +179,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
buf << "[";
for (size_t i = 0; i < p->GetCount(); i++) {
CPDF_Object* pElement = p->GetObjectAt(i);
- if (pElement->GetObjNum()) {
+ if (pElement && pElement->GetObjNum()) {
buf << " " << pElement->GetObjNum() << " 0 R";
} else {
buf << pElement;