Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1812)

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1385803002: Fix a leak in CPDF_SyntaxParser::GetObject(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: add todo Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index d486cfe231a7efb7759fa5921bd1a0f85b2fe467..27cc8688cc256378f3e90da37234c75da7612d73 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2139,6 +2139,13 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList,
++nKeys;
key = PDF_NameDecode(key);
+ if (key.IsEmpty())
+ continue;
+
+ CFX_ByteStringC keyNoSlash(key.c_str() + 1, key.GetLength() - 1);
+ if (keyNoSlash.IsEmpty())
+ continue;
+
if (key == FX_BSTRC("/Contents"))
dwSignValuePos = m_Pos;
@@ -2146,14 +2153,12 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjects* pObjList,
if (!pObj)
continue;
- if (key.GetLength() >= 1) {
- if (nKeys < 32) {
- pDict->SetAt(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
- pObj);
- } else {
- pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
- pObj);
- }
+ // TODO(thestig): Remove this conditional once CPDF_Dictionary has a
+ // better underlying map implementation.
+ if (nKeys < 32) {
+ pDict->SetAt(keyNoSlash, pObj);
+ } else {
+ pDict->AddValue(keyNoSlash, pObj);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698