Adjust null object check
authorBo Xu <bo_xu@foxitsoftware.com>
Mon, 21 Jul 2014 17:02:07 +0000 (10:02 -0700)
committerBo Xu <bo_xu@foxitsoftware.com>
Mon, 21 Jul 2014 17:02:07 +0000 (10:02 -0700)
BUG=None
R=thakis@chromium.org

Review URL: https://codereview.chromium.org/396173003

core/src/fpdfdoc/doc_ap.cpp
core/src/fpdfdoc/doc_formfield.cpp

index 6a8ab37..0e2a75a 100644 (file)
@@ -253,7 +253,10 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
     if (!pFormDict) {
         return FALSE;
     }
-    CFX_ByteString DA = FPDF_GetFieldAttr(pAnnotDict, "DA") ? FPDF_GetFieldAttr(pAnnotDict, "DA")->GetString() : CFX_ByteString();
+    CFX_ByteString DA;
+    if (CPDF_Object* pDAObj = FPDF_GetFieldAttr(pAnnotDict, "DA")) {
+        DA = pDAObj->GetString();
+    }
     if (DA.IsEmpty()) {
         DA = pFormDict->GetString("DA");
     }
index e51acf9..eeba372 100644 (file)
@@ -1077,9 +1077,12 @@ FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify)
 }
 void CPDF_FormField::LoadDA()
 {
-    CFX_ByteString DA = FPDF_GetFieldAttr(m_pDict, "DA") ? FPDF_GetFieldAttr(m_pDict, "DA")->GetString() : CFX_ByteString();
-    if (DA.IsEmpty()) {
-        DA = m_pForm->m_pFormDict ? m_pForm->m_pFormDict->GetString("DA") : CFX_ByteString();
+    CFX_ByteString DA;
+    if (CPDF_Object* pObj_t = FPDF_GetFieldAttr(m_pDict, "DA")) {
+        DA = pObj_t->GetString();
+    }
+    if (DA.IsEmpty() && m_pForm->m_pFormDict) {
+        DA = m_pForm->m_pFormDict->GetString("DA");
     }
     if (DA.IsEmpty()) {
         return;