Fix a crashier due to incorrect type conversion
authorJUN FANG <jun_fang@foxitsoftware.com>
Mon, 13 Jul 2015 11:20:10 +0000 (04:20 -0700)
committerJUN FANG <jun_fang@foxitsoftware.com>
Mon, 13 Jul 2015 11:20:10 +0000 (04:20 -0700)
BUG=issue179
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/1217093006 .

core/src/fxge/android/fpf_skiafont.cpp

index 40b1886..2dad010 100644 (file)
@@ -159,12 +159,13 @@ int32_t CFPF_SkiaFont::GetItalicAngle() const
 FX_DWORD CFPF_SkiaFont::GetFontData(FX_DWORD dwTable, uint8_t* pBuffer, FX_DWORD dwSize)
 {
     if (!m_Face) {
-        return FALSE;
+        return 0;
     }
-    if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, (unsigned long*)&dwSize)) {
+    FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize);
+    if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) {
         return 0;
     }
-    return dwSize;
+    return pdfium::base::checked_cast<FX_DWORD>(ulSize);
 }
 FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset)
 {