summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/Field.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/Field.cpp')
-rw-r--r--fpdfsdk/javascript/Field.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 477b472e3c..92b473b231 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -2815,10 +2815,11 @@ bool Field::buttonGetIcon(CJS_Runtime* pRuntime,
const std::vector<CJS_Value>& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- int nface = 0;
- int iSize = params.size();
- if (iSize >= 1)
- nface = params[0].ToInt(pRuntime);
+ if (params.size() >= 1) {
+ int nFace = params[0].ToInt(pRuntime);
+ if (nFace < 0 || nFace > 2)
+ return false;
+ }
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
@@ -2837,19 +2838,6 @@ bool Field::buttonGetIcon(CJS_Runtime* pRuntime,
ASSERT(pObj.IsEmpty() == false);
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
- Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject();
-
- CPDF_Stream* pIconStream = nullptr;
- if (nface == 0)
- pIconStream = pFormControl->GetNormalIcon();
- else if (nface == 1)
- pIconStream = pFormControl->GetDownIcon();
- else if (nface == 2)
- pIconStream = pFormControl->GetRolloverIcon();
- else
- return false;
-
- pIcon->SetStream(pIconStream);
vRet = CJS_Value(pRuntime, pJS_Icon);
return true;
}