summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdftext.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-01-11 14:34:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-11 14:34:06 +0000
commit241752f3c188ed992a26618361e55b1d7f2be7cc (patch)
tree68cc3709bb5e5f83a8f357b64385c07a90c2f076 /fpdfsdk/fpdftext.cpp
parent96d6b4df3a96976bb3d9ba068a88bf655f3da856 (diff)
downloadpdfium-241752f3c188ed992a26618361e55b1d7f2be7cc.tar.xz
Change FPDFText_GetCharBox() to return a boolean.
BUG=pdfium:858 Change-Id: Id8b6c032d60894eaf14ae0ba52098a60b2485fca Reviewed-on: https://pdfium-review.googlesource.com/22731 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdftext.cpp')
-rw-r--r--fpdfsdk/fpdftext.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/fpdfsdk/fpdftext.cpp b/fpdfsdk/fpdftext.cpp
index bc86c1c099..68bf4f83d7 100644
--- a/fpdfsdk/fpdftext.cpp
+++ b/fpdfsdk/fpdftext.cpp
@@ -105,24 +105,26 @@ FPDF_EXPORT double FPDF_CALLCONV FPDFText_GetFontSize(FPDF_TEXTPAGE text_page,
return charinfo.m_FontSize;
}
-FPDF_EXPORT void FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
- int index,
- double* left,
- double* right,
- double* bottom,
- double* top) {
- if (!text_page)
- return;
+FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFText_GetCharBox(FPDF_TEXTPAGE text_page,
+ int index,
+ double* left,
+ double* right,
+ double* bottom,
+ double* top) {
+ if (!text_page || index < 0)
+ return false;
+
CPDF_TextPage* textpage = CPDFTextPageFromFPDFTextPage(text_page);
+ if (index >= textpage->CountChars())
+ return false;
- if (index < 0 || index >= textpage->CountChars())
- return;
FPDF_CHAR_INFO charinfo;
textpage->GetCharInfo(index, &charinfo);
*left = charinfo.m_CharBox.left;
*right = charinfo.m_CharBox.right;
*bottom = charinfo.m_CharBox.bottom;
*top = charinfo.m_CharBox.top;
+ return true;
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV