summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-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");