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

Unified Diff: core/src/fxcrt/fx_basic_array.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/fxcrt/extension.h ('k') | core/src/fxcrt/fx_basic_bstring.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_array.cpp
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index 43a5417c008a6a9021bc05708da85cc182995e32..5a2a2e54a189e94fbbc305ecc25684ac0701992e 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -39,6 +39,10 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize)
return FALSE;
}
m_pData = FX_Alloc(FX_BYTE, totalSize.ValueOrDie());
+ if (!m_pData) {
+ m_nSize = m_nMaxSize = 0;
+ return FALSE;
+ }
m_nSize = m_nMaxSize = nNewSize;
} else if (nNewSize <= m_nMaxSize) {
if (nNewSize > m_nSize) {
@@ -193,6 +197,10 @@ void* CFX_BaseSegmentedArray::Add()
}
if (m_IndexDepth == 0) {
void** pIndex = (void**)FX_Alloc(void*, m_IndexSize);
+ if (pIndex == NULL) {
+ FX_Free(pSegment);
+ return NULL;
+ }
pIndex[0] = m_pIndex;
pIndex[1] = pSegment;
m_pIndex = pIndex;
@@ -214,6 +222,10 @@ void* CFX_BaseSegmentedArray::Add()
}
if (m_DataSize == tree_size * m_SegmentSize) {
void** pIndex = (void**)FX_Alloc(void*, m_IndexSize);
+ if (pIndex == NULL) {
+ FX_Free(pSegment);
+ return NULL;
+ }
pIndex[0] = m_pIndex;
m_pIndex = pIndex;
m_IndexDepth ++;
@@ -224,6 +236,9 @@ void* CFX_BaseSegmentedArray::Add()
for (i = 1; i < m_IndexDepth; i ++) {
if (pSpot[seg_index / tree_size] == NULL) {
pSpot[seg_index / tree_size] = (void*)FX_Alloc(void*, m_IndexSize);
+ if (pSpot[seg_index / tree_size] == NULL) {
+ break;
+ }
}
pSpot = (void**)pSpot[seg_index / tree_size];
seg_index = seg_index % tree_size;
« no previous file with comments | « core/src/fxcrt/extension.h ('k') | core/src/fxcrt/fx_basic_bstring.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698