From 298880f334ff1b8a1f3414d8ea8c2103e7755300 Mon Sep 17 00:00:00 2001 From: tsepez Date: Wed, 21 Sep 2016 14:04:25 -0700 Subject: Use unique_ptr> in more places Review-Url: https://codereview.chromium.org/2358243002 --- core/fpdfdoc/cpdf_formfield.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'core/fpdfdoc') 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> 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"); -- cgit v1.2.3