summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-26 15:36:17 -0700
committerLei Zhang <thestig@chromium.org>2015-10-26 15:36:17 -0700
commitf7992b39cec908e549fb995acae477a9efba538b (patch)
tree394dcb06b0d8718aba6aa5e83dd67dd475276ca1 /core/src/fpdfapi/fpdf_page
parentd50b640e42d46ab0f4d69cc58b3ba54e6137749c (diff)
downloadpdfium-f7992b39cec908e549fb995acae477a9efba538b.tar.xz
Remove default argument from CPDF_Dictionary::SetAt().
Also fix a potential object leak. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1414963005 .
Diffstat (limited to 'core/src/fpdfapi/fpdf_page')
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index b86d00851c..694d5234a8 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -77,11 +77,14 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
m_pSyntax->GetWordSize() - 1);
- CPDF_Object* pObj = m_pSyntax->ReadNextObject();
+ nonstd::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
+ m_pSyntax->ReadNextObject());
if (!key.IsEmpty()) {
- pDict->SetAt(key, pObj, m_pDocument);
- } else if (pObj) {
- pObj->Release();
+ FX_DWORD dwObjNum = pObj->GetObjNum();
+ if (dwObjNum)
+ pDict->SetAtReference(key, m_pDocument, dwObjNum);
+ else
+ pDict->SetAt(key, pObj.release());
}
}
_PDF_ReplaceAbbr(pDict);
@@ -95,7 +98,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name);
if (pCSObj && !pCSObj->GetObjNum()) {
pCSObj = pCSObj->Clone();
- pDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument);
+ pDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj);
}
}
}