From c116e597ef4dfac88248d6de0e7c9bdf093b6e7c Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 29 Aug 2016 13:08:25 -0700 Subject: 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 --- core/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- cgit v1.2.3