diff options
author | Lei Zhang <thestig@chromium.org> | 2017-05-04 14:10:50 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-04 21:25:26 +0000 |
commit | b8a8c43f394277d1f87320a4f01b4d5c38e81113 (patch) | |
tree | d7e0ffa2d9ed7aa9e31e506538aa450ecabed937 /fpdfsdk/fpdfedittext.cpp | |
parent | d74da7bb34abdae254df64ba2c0da7a581f6dae0 (diff) | |
download | pdfium-b8a8c43f394277d1f87320a4f01b4d5c38e81113.tar.xz |
CPDF_Document::GetPageData() normally does not return NULL.
Add a comment to clarify and remove some unneeded checks.
Change-Id: I8b0492548b245abc45e161085047c9f36d6c8e2b
Reviewed-on: https://pdfium-review.googlesource.com/4871
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfedittext.cpp')
-rw-r--r-- | fpdfsdk/fpdfedittext.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/fpdfsdk/fpdfedittext.cpp b/fpdfsdk/fpdfedittext.cpp index 4ff2269c9e..9b01775235 100644 --- a/fpdfsdk/fpdfedittext.cpp +++ b/fpdfsdk/fpdfedittext.cpp @@ -431,23 +431,28 @@ DLLEXPORT void STDCALL FPDFFont_Close(FPDF_FONT font) { if (!font) return; - CPDF_Font* cpdf_font = reinterpret_cast<CPDF_Font*>(font); - CPDF_Document* pDoc = cpdf_font->GetDocument(); - CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr; - if (pPageData && !pPageData->IsForceClear()) - pPageData->ReleaseFont(cpdf_font->GetFontDict()); + CPDF_Font* pFont = reinterpret_cast<CPDF_Font*>(font); + CPDF_Document* pDoc = pFont->GetDocument(); + if (!pDoc) + return; + + CPDF_DocPageData* pPageData = pDoc->GetPageData(); + if (!pPageData->IsForceClear()) + pPageData->ReleaseFont(pFont->GetFontDict()); } DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, FPDF_FONT font, float font_size) { + if (!font) + return nullptr; + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); - if (!pDoc || !font) + if (!pDoc) return nullptr; CPDF_Font* pFont = reinterpret_cast<CPDF_Font*>(font); - auto pTextObj = pdfium::MakeUnique<CPDF_TextObject>(); pTextObj->m_TextState.SetFont(pDoc->LoadFont(pFont->GetFontDict())); pTextObj->m_TextState.SetFontSize(font_size); |