summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-06-01 18:02:24 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-01 18:02:24 +0000
commitc05ddc26a1e9c150d8f6ce60b08ea0b595143d9d (patch)
tree8784f367dae47bf821905a3d57a0f80495f393e4 /xfa/fxfa
parentb80edf3fcb286c3265341c8905f0885c1d535d08 (diff)
downloadpdfium-c05ddc26a1e9c150d8f6ce60b08ea0b595143d9d.tar.xz
Clean up some issues found in CXFA_TextLayout
Initialize pCharPos to non-NULL, so that later code can depend on it != nullptr, avoiding a potential call to memset on nullptr. Additionally get rid of a free then alloc pattern and just use realloc. Later on remove updates to fBaseLineTemp that have not effect, since it isn't read after them. Issues found with Clang Static Analyzer. Change-Id: Iff175e20cd8860d263a56a24c8781e214c61d02c Reviewed-on: https://pdfium-review.googlesource.com/33533 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 749ce2d3f9..c0f786bbcf 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -560,8 +560,8 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
Layout(i);
}
- FXTEXT_CHARPOS* pCharPos = nullptr;
- int32_t iCharCount = 0;
+ FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, 1);
+ int32_t iCharCount = 1;
int32_t iLineStart = 0;
int32_t iPieceLines = pdfium::CollectionSize<int32_t>(m_pieceLines);
int32_t iCount = pdfium::CollectionSize<int32_t>(m_Blocks);
@@ -586,8 +586,7 @@ bool CXFA_TextLayout::DrawString(CFX_RenderDevice* pFxDevice,
const CXFA_TextPiece* pPiece = pPieceLine->m_textPieces[j].get();
int32_t iChars = pPiece->iChars;
if (iCharCount < iChars) {
- FX_Free(pCharPos);
- pCharPos = FX_Alloc(FXTEXT_CHARPOS, iChars);
+ pCharPos = FX_Realloc(FXTEXT_CHARPOS, pCharPos, iChars);
iCharCount = iChars;
}
memset(pCharPos, 0, iCharCount * sizeof(FXTEXT_CHARPOS));
@@ -1045,10 +1044,6 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus,
float fLineHeightTmp = fBaseLineTemp + pTP->rtPiece.height;
if (fLineHeight < fLineHeightTmp)
fLineHeight = fLineHeightTmp;
- else
- fBaseLineTemp = 0;
- } else if (fBaseLine < -fBaseLineTemp) {
- fBaseLine = -fBaseLineTemp;
}
fLineStep = std::max(fLineStep, fLineHeight);
pTP->pLinkData = pUserData ? pUserData->m_pLinkData : nullptr;