Change type of `CFDE_TextOut::m_iCurLine` to size_t.
This member variable is used to index into an array, so it is never
negative.
Bug: pdfium:774
Change-Id: Iabfc23754e01cf7adf2326ac52a7417bfb02345b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/95170
Reviewed-by: Nigi <nigi@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 67c5185..0b9441a 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -346,7 +346,7 @@
m_fLinePos += fLineStep;
}
if (m_fLinePos + fLineStep > fLineStop) {
- int32_t iCurLine = bEndofLine ? m_iCurLine - 1 : m_iCurLine;
+ size_t iCurLine = bEndofLine ? m_iCurLine - 1 : m_iCurLine;
m_ttoLines[iCurLine].set_new_reload(true);
bRet = true;
break;
@@ -424,13 +424,13 @@
void CFDE_TextOut::AppendPiece(const Piece& piece,
bool bNeedReload,
bool bEnd) {
- if (m_iCurLine >= fxcrt::CollectionSize<int32_t>(m_ttoLines)) {
+ if (m_iCurLine >= m_ttoLines.size()) {
Line ttoLine;
ttoLine.set_new_reload(bNeedReload);
m_iCurPiece = ttoLine.AddPiece(m_iCurPiece, piece);
m_ttoLines.push_back(ttoLine);
- m_iCurLine = fxcrt::CollectionSize<int32_t>(m_ttoLines) - 1;
+ m_iCurLine = m_ttoLines.size() - 1;
} else {
Line* pLine = &m_ttoLines[m_iCurLine];
pLine->set_new_reload(bNeedReload);
@@ -447,7 +447,7 @@
}
void CFDE_TextOut::Reload(const CFX_RectF& rect) {
- int i = 0;
+ size_t i = 0;
for (auto& line : m_ttoLines) {
if (line.new_reload()) {
m_iCurLine = i;
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index 09e9e85..b7bc270 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -115,7 +115,7 @@
WideString m_wsText;
CFX_Matrix m_Matrix;
std::deque<Line> m_ttoLines;
- int32_t m_iCurLine = 0;
+ size_t m_iCurLine = 0;
size_t m_iCurPiece = 0;
int32_t m_iTotalLines = 0;
std::vector<TextCharPos> m_CharPos;