summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/include/fxcrt/fx_basic.h8
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp7
2 files changed, 12 insertions, 3 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index 661722e1b2..fa536004d4 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -1085,6 +1085,13 @@ class CFX_AutoRestorer {
T m_OldValue;
};
+// Used with nonstd::unique_ptr to Release() objects that can't be deleted.
+template <class T>
+struct ReleaseDeleter {
+ inline void operator()(T* ptr) const { ptr->Release(); }
+};
+
+// TODO(thestig) Remove in favor of nonstd::unique_ptr.
template <class T>
class CFX_SmartPointer {
public:
@@ -1097,6 +1104,7 @@ class CFX_SmartPointer {
protected:
T* m_pObj;
};
+
#define FX_DATALIST_LENGTH 1024
template <size_t unit>
class CFX_SortListArray {
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) {