| Index: core/src/fpdfdoc/doc_ap.cpp
|
| diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
|
| index 784d89daed7c74c7a6c4d45b556e3b5fe9b2197f..6a8ab374d21e7150339d2f4258977eef8b25c6d6 100644
|
| --- a/core/src/fpdfdoc/doc_ap.cpp
|
| +++ b/core/src/fpdfdoc/doc_ap.cpp
|
| @@ -10,11 +10,11 @@
|
| #include "../../include/fpdfdoc/fpdf_ap.h"
|
| FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict)
|
| {
|
| - if (pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget")) {
|
| + if (!pAnnotDict || pAnnotDict->GetConstString("Subtype") != FX_BSTRC("Widget")) {
|
| return FALSE;
|
| }
|
| CFX_ByteString field_type = FPDF_GetFieldAttr(pAnnotDict, "FT")->GetString();
|
| - FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger();
|
| + FX_DWORD flags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
|
| if (field_type == "Tx") {
|
| return CPVT_GenerateAP::GenerateTextFieldAP(pDoc, pAnnotDict);
|
| } else if (field_type == "Ch") {
|
| @@ -253,7 +253,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
|
| if (!pFormDict) {
|
| return FALSE;
|
| }
|
| - CFX_ByteString DA = FPDF_GetFieldAttr(pAnnotDict, "DA")->GetString();
|
| + CFX_ByteString DA = FPDF_GetFieldAttr(pAnnotDict, "DA") ? FPDF_GetFieldAttr(pAnnotDict, "DA")->GetString() : CFX_ByteString();
|
| if (DA.IsEmpty()) {
|
| DA = pFormDict->GetString("DA");
|
| }
|
| @@ -277,7 +277,7 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
|
| bUseFormRes = TRUE;
|
| }
|
| CPDF_Dictionary * pDRFontDict = NULL;
|
| - if ((pDRFontDict = pDRDict->GetDict("Font"))) {
|
| + if (pDRDict && (pDRFontDict = pDRDict->GetDict("Font"))) {
|
| pFontDict = pDRFontDict->GetDict(sFontName.Mid(1));
|
| if (!pFontDict && !bUseFormRes) {
|
| pDRDict = pFormDict->GetDict(FX_BSTRC("DR"));
|
| @@ -430,11 +430,11 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
|
| }
|
| switch (nWidgetType) {
|
| case 0: {
|
| - CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText();
|
| - FX_INT32 nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger();
|
| - FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger();
|
| - FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger();
|
| - CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| + CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
|
| + FX_INT32 nAlign = FPDF_GetFieldAttr(pAnnotDict, "Q")? FPDF_GetFieldAttr(pAnnotDict, "Q")->GetInteger() : 0;
|
| + FX_DWORD dwFlags = FPDF_GetFieldAttr(pAnnotDict, "Ff")? FPDF_GetFieldAttr(pAnnotDict, "Ff")->GetInteger() : 0;
|
| + FX_DWORD dwMaxLen = FPDF_GetFieldAttr(pAnnotDict, "MaxLen") ? FPDF_GetFieldAttr(pAnnotDict, "MaxLen")->GetInteger() : 0;
|
| + CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources") : NULL , pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| CPVT_Provider prd(&map);
|
| CPDF_VariableText vt;
|
| vt.SetProvider(&prd);
|
| @@ -482,8 +482,8 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
|
| }
|
| break;
|
| case 1: {
|
| - CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText();
|
| - CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| + CFX_WideString swValue = FPDF_GetFieldAttr(pAnnotDict, "V") ? FPDF_GetFieldAttr(pAnnotDict, "V")->GetUnicodeText() : CFX_WideString();
|
| + CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| CPVT_Provider prd(&map);
|
| CPDF_VariableText vt;
|
| vt.SetProvider(&prd);
|
| @@ -534,11 +534,11 @@ static FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict
|
| }
|
| break;
|
| case 2: {
|
| - CPVT_FontMap map(pDoc, pStreamDict->GetDict("Resources"), pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| + CPVT_FontMap map(pDoc, pStreamDict ? pStreamDict->GetDict("Resources"):NULL, pDefFont, sFontName.Right(sFontName.GetLength() - 1));
|
| CPVT_Provider prd(&map);
|
| - CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray();
|
| - CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray();
|
| - FX_INT32 nTop = FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger();
|
| + CPDF_Array * pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt") ? FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray() : NULL;
|
| + CPDF_Array * pSels = FPDF_GetFieldAttr(pAnnotDict, "I") ? FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray() : NULL;
|
| + FX_INT32 nTop = FPDF_GetFieldAttr(pAnnotDict, "TI") ? FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger() : 0;
|
| CFX_ByteTextBuf sBody;
|
| if (pOpts) {
|
| FX_FLOAT fy = rcBody.top;
|
|
|