Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: core/src/fxge/ge/fx_ge_fontmap.cpp

Issue 1145843005: Revert "Remove FX_Alloc() null checks now that it can't return NULL." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_path.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxge/ge/fx_ge_fontmap.cpp
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 74f97d1b2edcfa221239e59d0e62f45289787466..f058f03bceee22a1b096bdb5eaee15eeffdd385a 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -564,6 +564,9 @@ CFX_ByteString CFX_FontMapper::GetPSNameFromTT(void* hFont)
FX_DWORD size = m_pFontInfo->GetFontData(hFont, 0x6e616d65, NULL, 0);
if (size) {
FX_LPBYTE buffer = FX_Alloc(FX_BYTE, size);
+ if (!buffer) {
+ return result;
+ }
m_pFontInfo->GetFontData(hFont, 0x6e616d65, buffer, size);
result = _FPDF_GetNameFromTT(buffer, 6);
FX_Free(buffer);
@@ -1206,15 +1209,21 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const CFX_ByteString& name, FX_BOOL bTru
face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_size, pFontData);
if (face == NULL) {
pFontData = FX_Alloc(FX_BYTE, ttc_size);
- m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size);
- face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, ttc_size,
- ttc_size - font_size);
+ if (pFontData) {
+ m_pFontInfo->GetFontData(hFont, 0x74746366, pFontData, ttc_size);
+ face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData, ttc_size,
+ ttc_size - font_size);
+ }
}
} else {
FX_LPBYTE pFontData;
face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData);
if (face == NULL) {
pFontData = FX_Alloc(FX_BYTE, font_size);
+ if (!pFontData) {
+ m_pFontInfo->DeleteFont(hFont);
+ return NULL;
+ }
m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData, font_size, m_pFontInfo->GetFaceIndex(hFont));
}
@@ -1371,6 +1380,10 @@ void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path)
}
FX_DWORD face_bytes = nFaces * 4;
FX_LPBYTE offsets = FX_Alloc(FX_BYTE, face_bytes);
+ if (!offsets) {
+ FXSYS_fclose(pFile);
+ return;
+ }
readCnt = FXSYS_fread(offsets, face_bytes, 1, pFile);
if (readCnt != face_bytes) {
FX_Free(offsets);
« no previous file with comments | « core/src/fxge/ge/fx_ge_font.cpp ('k') | core/src/fxge/ge/fx_ge_path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698