summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_parser
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-22 21:53:22 -0700
committerLei Zhang <thestig@chromium.org>2015-09-22 21:53:22 -0700
commit13fe8c9d74607610b3a535c7edf911eaa8711318 (patch)
treeabfc392171d0ace3144035903f7d930c78a9c96c /core/src/fpdfapi/fpdf_parser
parent0244d40daf39caf97f47de9982f4aac88c0c8644 (diff)
downloadpdfium-13fe8c9d74607610b3a535c7edf911eaa8711318.tar.xz
Merge to XFA: Change nonstd::unique_ptr to take a custom deleter.
Code is mostly stolen from Chromium's scoped_ptr. - Add unit tests. - Use this to fix a leak. BUG=chromium:531408 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1351383004 . (cherry picked from commit cef2a9c51bee4b987fc813013d45dad6535a9a46) Review URL: https://codereview.chromium.org/1358163003 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_parser')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 4c2bb346a1..5909d0f758 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2385,8 +2385,9 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
continue;
}
key = PDF_NameDecode(key);
- CPDF_Object* pObj = GetObject(pObjList, objnum, gennum);
- if (pObj == NULL) {
+ nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj(
+ GetObject(pObjList, objnum, gennum));
+ if (!obj) {
if (pDict) {
pDict->Release();
}
@@ -2403,7 +2404,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectByStrict(
}
if (key.GetLength() > 1) {
pDict->AddValue(CFX_ByteStringC(key.c_str() + 1, key.GetLength() - 1),
- pObj);
+ obj.release());
}
}
if (pContext) {