summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-09-21 14:04:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-21 14:04:25 -0700
commit298880f334ff1b8a1f3414d8ea8c2103e7755300 (patch)
tree19aa99e6c7835f24baad0c911b4637c3e6aa0a1d /core/fpdfdoc
parent17103b84ebde9ab2b05dff38d473b5d44f723ff2 (diff)
downloadpdfium-298880f334ff1b8a1f3414d8ea8c2103e7755300.tar.xz
Use unique_ptr<CPDF_Object, ReleaseDeleter<>> in more placeschromium/2868
Review-Url: https://codereview.chromium.org/2358243002
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index cbce1aaf69..38f7648e0b 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -577,17 +577,16 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index,
if (pValue->GetUnicodeText() == opt_value)
m_pDict->RemoveFor("V");
} else if (pValue->IsArray()) {
- CPDF_Array* pArray = new CPDF_Array;
+ std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray(
+ new CPDF_Array);
for (int i = 0; i < CountOptions(); i++) {
if (i != index && IsItemSelected(i)) {
opt_value = GetOptionValue(i);
pArray->AddString(PDF_EncodeText(opt_value));
}
}
- if (pArray->GetCount() < 1)
- pArray->Release();
- else
- m_pDict->SetFor("V", pArray);
+ if (pArray->GetCount() > 0)
+ m_pDict->SetFor("V", pArray.release()); // std::move someday
}
} else {
m_pDict->RemoveFor("V");