Add a null check before getting unicode text in CPDF_FormField::GetValue
authorJun Fang <jun_fang@foxitsoftware.com>
Mon, 18 Aug 2014 18:30:19 +0000 (11:30 -0700)
committerJun Fang <jun_fang@foxitsoftware.com>
Mon, 18 Aug 2014 18:30:19 +0000 (11:30 -0700)
The test pdf file defines an invalid dictionary object with a NULL arrary
in the filed of "/V". It causes that a NULL object is returned when trying
to get the first element of this arrary. So it needs to check whether the
returned object is NULL.

BUG=395986
R=tsepez@chromium.org

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

core/src/fpdfdoc/doc_formfield.cpp

index eeba372..a2f0fbd 100644 (file)
@@ -324,7 +324,9 @@ CFX_WideString CPDF_FormField::GetValue(FX_BOOL bDefault)
             return pValue->GetUnicodeText();
         case PDFOBJ_ARRAY:
             pValue = ((CPDF_Array*)pValue)->GetElementValue(0);
-            return pValue->GetUnicodeText();
+            if (pValue) {
+                return pValue->GetUnicodeText();
+            }
             break;
     }
     return CFX_WideString();