summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font/cpdf_font.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-14 15:53:36 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-15 00:03:38 +0000
commit193e6ca5e48ee99e620f0e7546f1407ba1a20323 (patch)
tree11d920c59a89247d28fe590d77ab6d6a9ce37a0c /core/fpdfapi/font/cpdf_font.cpp
parentcd5139a291113f177d3494990efbcaf388d1f3bf (diff)
downloadpdfium-193e6ca5e48ee99e620f0e7546f1407ba1a20323.tar.xz
Add IndexInBounds() convenience routine.
Avoid writing |Type| in CollectionSize<Type>() so that index type can change without rewriting conditions. Change-Id: I40c94ca39148b379908760ba9b861114b88af7bb Reviewed-on: https://pdfium-review.googlesource.com/3056 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/font/cpdf_font.cpp')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index 7988ec7124..f0b5ac16b7 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -458,10 +458,9 @@ uint32_t CPDF_Font::FallbackFontFromCharcode(uint32_t charcode) {
}
int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) {
- if (fallbackFont < 0 ||
- fallbackFont >= pdfium::CollectionSize<int>(m_FontFallbacks)) {
+ if (!pdfium::IndexInBounds(m_FontFallbacks, fallbackFont))
return -1;
- }
+
int glyph =
FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode);
if (glyph == 0 || glyph == 0xffff)