Re-land: Remove FX_Alloc() null checks now that it can't return NULL.

Fixes the ordering of some assignments broken when converting to checked
numerics in CFX_PathData::AddPointCount().

Original Review URL: https://codereview.chromium.org/1142713005

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1135893008
diff --git a/core/include/fxcodec/fx_codec_def.h b/core/include/fxcodec/fx_codec_def.h
index 0d08da6..497d4d8 100644
--- a/core/include/fxcodec/fx_codec_def.h
+++ b/core/include/fxcodec/fx_codec_def.h
@@ -13,7 +13,6 @@
     FXCODEC_STATUS_DECODE_READY,
     FXCODEC_STATUS_DECODE_TOBECONTINUE,
     FXCODEC_STATUS_DECODE_FINISH,
-    FXCODEC_STATUS_ERR_MEMORY,
     FXCODEC_STATUS_ERR_READ,
     FXCODEC_STATUS_ERR_FLUSH,
     FXCODEC_STATUS_ERR_FORMAT,
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index f9c4e9b..147e24c 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -186,11 +186,9 @@
         return m_pPoints;
     }
 
-    FX_BOOL				SetPointCount(int nPoints);
-
-    FX_BOOL				AllocPointCount(int nPoints);
-
-    FX_BOOL				AddPointCount(int addPoints);
+    void SetPointCount(int nPoints);
+    void AllocPointCount(int nPoints);
+    void AddPointCount(int addPoints);
 
     CFX_FloatRect		GetBoundingBox() const;
 
@@ -204,15 +202,14 @@
 
     FX_BOOL				IsRect(const CFX_AffineMatrix* pMatrix, CFX_FloatRect* rect) const;
 
-    FX_BOOL				Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix);
-
-    FX_BOOL				AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
+    void Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix);
+    void AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top);
 
     void				SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag);
 
     void				TrimPoints(int nPoints);
 
-    FX_BOOL				Copy(const CFX_PathData &src);
+    void Copy(const CFX_PathData &src);
 protected:
     friend class		CPDF_Path;
 
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index 0886d3f..3abbcee 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -415,9 +415,6 @@
     }
     m_dwSize = pHandler->EncryptGetSize(objnum, 0, src_data, src_size);
     m_pData = FX_Alloc(FX_BYTE, m_dwSize);
-    if(!m_pData) {
-        return FALSE;
-    }
     pHandler->EncryptContent(objnum, 0, src_data, src_size, m_pData, m_dwSize);
     m_bNewBuf = TRUE;
     return TRUE;
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
index 1328fcd..a5a91eb 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
@@ -71,17 +71,11 @@
         dwEstimateSize = 8192;
     }
     FX_LPBYTE pData = FX_Alloc(FX_BYTE, dwEstimateSize);
-    if (!pData) {
-        return;
-    }
     pFile->ReadBlock(pData, 0, dwEstimateSize);
     CPDF_Dictionary *pDict = InitJPEG(pData, dwEstimateSize);
     FX_Free(pData);
     if (!pDict && size > dwEstimateSize) {
         pData = FX_Alloc(FX_BYTE, size);
-        if (!pData) {
-            return;
-        }
         pFile->ReadBlock(pData, 0, size);
         pDict = InitJPEG(pData, size);
         FX_Free(pData);
@@ -223,8 +217,8 @@
         } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) {
             _JBIG2EncodeBitmap(pMaskDict, pMaskBitmap, m_pDocument, mask_buf, mask_size, TRUE);
         } else {
-            mask_size = maskHeight * maskWidth;
-            mask_buf = FX_Alloc(FX_BYTE, mask_size);
+            mask_buf = FX_Alloc2D(FX_BYTE, maskHeight, maskWidth);
+            mask_size = maskHeight * maskWidth;  // Safe since checked alloc returned.
             for (FX_INT32 a = 0; a < maskHeight; a ++) {
                 FXSYS_memcpy32(mask_buf + a * maskWidth, pMaskBitmap->GetScanline(a), maskWidth);
             }
@@ -306,8 +300,8 @@
         }
     } else if (opType == 1) {
         if (!bStream) {
-            dest_size = dest_pitch * BitmapHeight;
-            dest_buf = FX_Alloc(FX_BYTE, dest_size);
+            dest_buf = FX_Alloc2D(FX_BYTE, dest_pitch, BitmapHeight);
+            dest_size = dest_pitch * BitmapHeight;  // Safe since checked alloc returned.
         }
         FX_LPBYTE pDest = dest_buf;
         for (FX_INT32 i = 0; i < BitmapHeight; i ++) {
@@ -321,8 +315,8 @@
         }
     } else if (opType == 2) {
         if (!bStream) {
-            dest_size = dest_pitch * BitmapHeight;
-            dest_buf = FX_Alloc(FX_BYTE, dest_size);
+            dest_buf = FX_Alloc2D(FX_BYTE, dest_pitch, BitmapHeight);
+            dest_size = dest_pitch * BitmapHeight;  // Safe since checked alloc returned.
         } else {
             dest_buf = FX_Alloc(FX_BYTE, dest_pitch);
         }
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index 4ec753d..5a9f1a8 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -204,11 +204,10 @@
     if (m_nChars > 1) {
         m_pCharCodes = FX_Alloc(FX_DWORD, m_nChars);
         m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
-        int i;
-        for (i = 0; i < m_nChars; i ++) {
+        for (int i = 0; i < m_nChars; i ++) {
             m_pCharCodes[i] = pSrcObj->m_pCharCodes[i];
         }
-        for (i = 0; i < m_nChars - 1; i ++) {
+        for (int i = 0; i < m_nChars - 1; i ++) {
             m_pCharPos[i] = pSrcObj->m_pCharPos[i];
         }
     } else {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index 952fe1d..d8b2459 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -262,8 +262,8 @@
         delete pDecoder;
         return -1;
     }
-    dest_size = pitch * height;
-    dest_buf = FX_Alloc( FX_BYTE, dest_size);
+    dest_buf = FX_Alloc2D(FX_BYTE, pitch, height);
+    dest_size = pitch * height;  // Safe since checked alloc returned.
     for (int row = 0; row < height; row ++) {
         FX_LPBYTE pLine = pDecoder->GetScanline(row);
         if (pLine == NULL) {
@@ -1050,10 +1050,6 @@
                         m_Size += size + 1;
                     }
                     m_pData = FX_Alloc(FX_BYTE, m_Size);
-                    if (!m_pData) {
-                        m_Status = Done;
-                        return;
-                    }
                     FX_DWORD pos = 0;
                     for (i = 0; i < m_nStreams; i ++) {
                         FXSYS_memcpy32(m_pData + pos, m_pStreamArray[i]->GetData(), m_pStreamArray[i]->GetSize());
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 8f5871d..691981c 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -40,9 +40,6 @@
         return (FX_DWORD) - 1;
     }
     dest_buf = FX_Alloc(FX_BYTE, zcount * 4 + (pos - zcount));
-    if (dest_buf == NULL) {
-        return (FX_DWORD) - 1;
-    }
     int state = 0;
     FX_UINT32 res = 0;
     pos = dest_size = 0;
@@ -153,9 +150,6 @@
         return -1;
     }
     dest_buf = FX_Alloc( FX_BYTE, dest_size);
-    if (!dest_buf) {
-        return -1;
-    }
     i = 0;
     int dest_count = 0;
     while (i < src_size) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 3eac5ae..341be13 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -1086,7 +1086,7 @@
     }
     if (!pStream->IsMemoryBased()) {
         pSrcData = m_pSrcData = FX_Alloc(FX_BYTE, dwSrcSize);
-        if (!pSrcData || !pStream->ReadRawData(0, pSrcData, dwSrcSize)) {
+        if (!pStream->ReadRawData(0, pSrcData, dwSrcSize)) {
             return;
         }
     } else {
@@ -1165,9 +1165,6 @@
         return p;
     }
     FX_LPBYTE p = FX_Alloc(FX_BYTE, m_dwSize);
-    if (p == NULL) {
-        return NULL;
-    }
     FXSYS_memcpy32(p, m_pData, m_dwSize);
     return p;
 }
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 2772d98..0d4ed27 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2477,9 +2477,6 @@
     }
     CPDF_Stream* pStream;
     FX_LPBYTE pData = FX_Alloc(FX_BYTE, len);
-    if (!pData) {
-        return NULL;
-    }
     ReadBlock(pData, len);
     if (pCryptoHandler) {
         CFX_BinaryBuf dest_buf;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 7093eda..b45d9c3 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -500,9 +500,6 @@
         return NULL;
     }
     DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents);
-    if (pCompData == NULL) {
-        return NULL;
-    }
     int max_data = (1 << m_bpc) - 1;
     CPDF_Array* pDecode = m_pDict->GetArray(FX_BSTRC("Decode"));
     if (pDecode) {
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 4ccce21..0ddcb23 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -339,9 +339,6 @@
                 dash_count ++;
             }
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
-            if (pGraphState->m_DashArray == NULL) {
-                return NULL;
-            }
             pGraphState->m_DashCount = dash_count;
             FX_DWORD i;
             for (i = 0; i < pDashArray->GetCount(); i ++) {
@@ -352,9 +349,6 @@
             }
         } else {
             pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);
-            if (pGraphState->m_DashArray == NULL) {
-                return NULL;
-            }
             pGraphState->m_DashCount = 2;
             pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f;
         }
@@ -441,9 +435,6 @@
                 dash_count ++;
             }
             graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count);
-            if (graph_state.m_DashArray == NULL) {
-                return ;
-            }
             graph_state.m_DashCount = dash_count;
             FX_DWORD i;
             for (i = 0; i < pDashArray->GetCount(); i ++) {
@@ -454,9 +445,6 @@
             }
         } else {
             graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2);
-            if (graph_state.m_DashArray == NULL) {
-                return ;
-            }
             graph_state.m_DashCount = 2;
             graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f;
         }
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index a0b0104..e58b50d 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -223,45 +223,43 @@
     }
     if (m_bAutoWidth) {
         int* widths = FX_Alloc(int, m_BaseLines.GetSize());
-        if (widths) {
-            for (i = 0; i < m_BaseLines.GetSize(); i ++) {
-                widths[i] = 0;
-                CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
-                int TotalChars = 0;
-                FX_FLOAT TotalWidth = 0;
-                int minchars;
-                pBaseLine->CountChars(TotalChars, TotalWidth, minchars);
-                if (TotalChars) {
-                    FX_FLOAT charwidth = TotalWidth / TotalChars;
-                    widths[i] = (int)((MaxRightX - MinLeftX) / charwidth);
-                }
-                if (widths[i] > 1000) {
-                    widths[i] = 1000;
-                }
-                if (widths[i] < minchars) {
-                    widths[i] = minchars;
-                }
+        for (i = 0; i < m_BaseLines.GetSize(); i ++) {
+            widths[i] = 0;
+            CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
+            int TotalChars = 0;
+            FX_FLOAT TotalWidth = 0;
+            int minchars;
+            pBaseLine->CountChars(TotalChars, TotalWidth, minchars);
+            if (TotalChars) {
+                FX_FLOAT charwidth = TotalWidth / TotalChars;
+                widths[i] = (int)((MaxRightX - MinLeftX) / charwidth);
             }
-            int AvgWidth = 0, widthcount = 0;
-            for (i = 0; i < m_BaseLines.GetSize(); i ++)
-                if (widths[i]) {
-                    AvgWidth += widths[i];
-                    widthcount ++;
-                }
-            AvgWidth = int((FX_FLOAT)AvgWidth / widthcount + 0.5);
-            int MaxWidth = 0;
-            for (i = 0; i < m_BaseLines.GetSize(); i ++)
-                if (MaxWidth < widths[i]) {
-                    MaxWidth = widths[i];
-                }
-            if (MaxWidth > AvgWidth * 6 / 5) {
-                MaxWidth = AvgWidth * 6 / 5;
+            if (widths[i] > 1000) {
+                widths[i] = 1000;
             }
-            FX_Free(widths);
-            if (iMinWidth < MaxWidth) {
-                iMinWidth = MaxWidth;
+            if (widths[i] < minchars) {
+                widths[i] = minchars;
             }
         }
+        int AvgWidth = 0, widthcount = 0;
+        for (i = 0; i < m_BaseLines.GetSize(); i ++)
+            if (widths[i]) {
+                AvgWidth += widths[i];
+                widthcount ++;
+            }
+        AvgWidth = int((FX_FLOAT)AvgWidth / widthcount + 0.5);
+        int MaxWidth = 0;
+        for (i = 0; i < m_BaseLines.GetSize(); i ++)
+            if (MaxWidth < widths[i]) {
+                MaxWidth = widths[i];
+            }
+        if (MaxWidth > AvgWidth * 6 / 5) {
+            MaxWidth = AvgWidth * 6 / 5;
+        }
+        FX_Free(widths);
+        if (iMinWidth < MaxWidth) {
+            iMinWidth = MaxWidth;
+        }
     }
     for (i = 0; i < m_BaseLines.GetSize(); i ++) {
         CTextBaseLine* pBaseLine = (CTextBaseLine*)m_BaseLines.GetAt(i);
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 882b22c..69d0bc5 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -1164,9 +1164,6 @@
             FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
             if (nCount >= 1) {
                 pDst = FX_Alloc(FX_WCHAR, nCount);
-                if (!pDst) {
-                    return;
-                }
                 FX_Unicode_GetNormalization(wChar, pDst);
                 for (int nIndex = 0; nIndex < nCount; nIndex++) {
                     PAGECHAR_INFO Info2 = Info;
@@ -1199,9 +1196,6 @@
         FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst);
         if (nCount >= 1) {
             pDst = FX_Alloc(FX_WCHAR, nCount);
-            if (!pDst) {
-                return;
-            }
             FX_Unicode_GetNormalization(wChar, pDst);
             for (int nIndex = 0; nIndex < nCount; nIndex++) {
                 PAGECHAR_INFO Info2 = Info;
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index e8aad71..c325ccc 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -333,9 +333,6 @@
     m_Pitch = (width * nComps * bpc + 31) / 32 * 4;
     m_dwLineBytes = (width * nComps * bpc + 7) / 8;
     m_pScanline = FX_Alloc(FX_BYTE, m_Pitch);
-    if (m_pScanline == NULL) {
-        return FALSE;
-    }
     return CheckDestSize();
 }
 FX_BOOL CCodec_RLScanlineDecoder::v_Rewind()
diff --git a/core/src/fxcodec/codec/fx_codec_fax.cpp b/core/src/fxcodec/codec/fx_codec_fax.cpp
index 33e89e4..dc2ee2a 100644
--- a/core/src/fxcodec/codec/fx_codec_fax.cpp
+++ b/core/src/fxcodec/codec/fx_codec_fax.cpp
@@ -622,13 +622,7 @@
     m_OutputWidth = m_OrigWidth;
     m_OutputHeight = m_OrigHeight;
     m_pScanlineBuf = FX_Alloc(FX_BYTE, m_Pitch);
-    if (m_pScanlineBuf == NULL) {
-        return FALSE;
-    }
     m_pRefBuf = FX_Alloc(FX_BYTE, m_Pitch);
-    if (m_pRefBuf == NULL) {
-        return FALSE;
-    }
     m_pSrcBuf = src_buf;
     m_SrcSize = src_size;
     m_nComps = 1;
@@ -705,9 +699,6 @@
             pitch = (width + 7) / 8;
         }
         FX_LPBYTE ref_buf = FX_Alloc(FX_BYTE, pitch);
-        if (ref_buf == NULL) {
-            return;
-        }
         FXSYS_memset8(ref_buf, 0xff, pitch);
         int bitpos = *pbitpos;
         for (int iRow = 0; iRow < height; iRow ++) {
@@ -945,9 +936,6 @@
     m_Rows = height;
     m_Pitch = pitch;
     m_pRefLine = FX_Alloc(FX_BYTE, m_Pitch);
-    if (m_pRefLine == NULL) {
-        return;
-    }
     FXSYS_memset8(m_pRefLine, 0xff, m_Pitch);
     m_pLineBuf = FX_Alloc2D(FX_BYTE, m_Pitch, 8);
     m_DestBuf.EstimateSize(0, 10240);
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index 4d43cc5..7a19e8b 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -583,8 +583,8 @@
 public:
     CCodec_FlateScanlineDecoder();
     ~CCodec_FlateScanlineDecoder();
-    FX_BOOL		Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc,
-                       int predictor, int Colors, int BitsPerComponent, int Columns);
+    void Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc,
+                int predictor, int Colors, int BitsPerComponent, int Columns);
     virtual void		Destroy()
     {
         delete this;
@@ -630,7 +630,7 @@
         FPDFAPI_FlateEnd(m_pFlate);
     }
 }
-FX_BOOL CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
+void CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height,
         int nComps, int bpc, int predictor, int Colors, int BitsPerComponent, int Columns)
 {
     m_SrcBuf = src_buf;
@@ -642,9 +642,6 @@
     m_bColorTransformed = FALSE;
     m_Pitch = (width * nComps * bpc + 7) / 8;
     m_pScanline = FX_Alloc(FX_BYTE, m_Pitch);
-    if (m_pScanline == NULL) {
-        return FALSE;
-    }
     m_Predictor = 0;
     if (predictor) {
         if (predictor >= 10) {
@@ -663,20 +660,10 @@
             m_Columns = Columns;
             m_PredictPitch = (m_BitsPerComponent * m_Colors * m_Columns + 7) / 8;
             m_pLastLine = FX_Alloc(FX_BYTE, m_PredictPitch);
-            if (m_pLastLine == NULL) {
-                return FALSE;
-            }
             m_pPredictRaw = FX_Alloc(FX_BYTE, m_PredictPitch + 1);
-            if (m_pPredictRaw == NULL) {
-                return FALSE;
-            }
             m_pPredictBuffer = FX_Alloc(FX_BYTE, m_PredictPitch);
-            if (m_pPredictBuffer == NULL) {
-                return FALSE;
-            }
         }
     }
-    return TRUE;
 }
 FX_BOOL CCodec_FlateScanlineDecoder::v_Rewind()
 {
@@ -752,8 +739,6 @@
 
     FX_LPBYTE guess_buf = FX_Alloc(FX_BYTE, guess_size + 1);
     FX_LPBYTE cur_buf = guess_buf;
-    if (!guess_buf)
-        goto fail;
     guess_buf[guess_size] = '\0';
     context = FPDFAPI_FlateInit(my_alloc_func, my_free_func);
     if (!context)
@@ -809,12 +794,6 @@
             // |avail_buf_size| == 0 case.
             result_tmp_bufs.Add(cur_buf);
             cur_buf = FX_Alloc(FX_BYTE, buf_size + 1);
-            if (!cur_buf) {
-                for (FX_INT32 i = 0; i < result_tmp_bufs.GetSize(); i++) {
-                    FX_Free(result_tmp_bufs[i]);
-                }
-                goto fail;
-            }
             cur_buf[buf_size] = '\0';
         }
         dest_size = FPDFAPI_FlateGetTotalOut(context);
@@ -823,12 +802,6 @@
             dest_buf = result_tmp_bufs[0];
         } else {
             FX_LPBYTE result_buf = FX_Alloc(FX_BYTE, dest_size);
-            if (!result_buf) {
-                for (FX_INT32 i = 0; i < result_tmp_bufs.GetSize(); i++) {
-                    FX_Free(result_tmp_bufs[i]);
-                }
-                goto fail;
-            }
             FX_DWORD result_pos = 0;
             for (FX_INT32 i = 0; i < result_tmp_bufs.GetSize(); i++) {
                 FX_LPBYTE tmp_buf = result_tmp_bufs[i];
@@ -887,9 +860,6 @@
         {
             nonstd::unique_ptr<CLZWDecoder> decoder(new CLZWDecoder);
             dest_buf = FX_Alloc( FX_BYTE, dest_size + 1);
-            if (dest_buf == NULL) {
-                return -1;
-            }
             dest_buf[dest_size] = '\0';
             decoder->Decode(dest_buf, dest_size, src_buf, offset, bEarlyChange);
         }
@@ -918,9 +888,6 @@
     }
     FX_LPBYTE pSrcBuf = NULL;
     pSrcBuf = FX_Alloc(FX_BYTE, src_size);
-    if (pSrcBuf == NULL) {
-        return FALSE;
-    }
     FXSYS_memcpy32(pSrcBuf, src_buf, src_size);
     FX_BOOL ret = TRUE;
     if (predictor == 2) {
@@ -939,9 +906,6 @@
 {
     dest_size = src_size + src_size / 1000 + 12;
     dest_buf = FX_Alloc( FX_BYTE, dest_size);
-    if (dest_buf == NULL) {
-        return FALSE;
-    }
     unsigned long temp_size = dest_size;
     FPDFAPI_FlateCompress(dest_buf, &temp_size, src_buf, src_size);
     dest_size = (FX_DWORD)temp_size;
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index a984fec..26b4c1a 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -285,9 +285,6 @@
     ICodec_IccModule::IccCS cs;
     FX_DWORD dwSize = (FX_DWORD)pFile->GetSize();
     FX_LPBYTE pBuf = FX_Alloc(FX_BYTE, dwSize);
-    if (pBuf == NULL) {
-        return IccCS_Unknown;
-    }
     pFile->ReadBlock(pBuf, 0, dwSize);
     cs = GetProfileCS(pBuf, dwSize);
     FX_Free(pBuf);
@@ -491,9 +488,6 @@
     CFX_IccTransformCache* pTransformCache;
     if (!m_MapTranform.Lookup(TransformKey, (FX_LPVOID&)pTransformCache)) {
         pCmm = FX_Alloc(CLcmsCmm, 1);
-        if (pCmm == NULL) {
-            return NULL;
-        }
         pCmm->m_nSrcComponents = T_CHANNELS(dwInputProfileType);
         pCmm->m_nDstComponents = T_CHANNELS(dwOutputProfileType);
         pCmm->m_bLab = T_COLORSPACE(pInputParam->dwFormat) == PT_Lab;
diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp
index 278d9cb..8fcd9f4 100644
--- a/core/src/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp
@@ -53,9 +53,6 @@
     CJBig2_Image* dest_image = NULL;
     FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize();
     FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size);
-    if (src_buf == NULL) {
-        return FALSE;
-    }
     int ret = 0;
     if(!file_ptr->ReadBlock(src_buf, 0, src_size)) {
         goto failed;
@@ -133,9 +130,6 @@
     m_pJbig2Context->m_dest_image = NULL;
     m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize();
     m_pJbig2Context->m_src_buf = FX_Alloc(FX_BYTE, m_pJbig2Context->m_src_size);
-    if (m_pJbig2Context->m_src_buf == NULL) {
-        return FXCODEC_STATUS_ERR_MEMORY;
-    }
     int ret = 0;
     if(!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0, m_pJbig2Context->m_src_size)) {
         goto failed;
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 3546f57..1a1616c 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -715,14 +715,8 @@
     }
     FXSYS_memset8(dest_buf, 0xff, image->y1 * pitch);
     FX_BYTE** channel_bufs = FX_Alloc(FX_BYTE*, image->numcomps);
-    if (channel_bufs == NULL) {
-        return FALSE;
-    }
     FX_BOOL result = FALSE;
     int* adjust_comps = FX_Alloc(int, image->numcomps);
-    if (adjust_comps == NULL) {
-        goto done;
-    }
     for (i = 0; i < (int)image->numcomps; i ++) {
         channel_bufs[i] = dest_buf + offsets[i];
         adjust_comps[i] = image->comps[i].prec - 8;
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h
index dbee7e6..c459bdc 100644
--- a/core/src/fxcrt/extension.h
+++ b/core/src/fxcrt/extension.h
@@ -348,9 +348,7 @@
         if (m_dwFlags & FX_MEMSTREAM_Consecutive) {
             if (m_Blocks.GetSize() < 1) {
                 FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, FX_MAX(nInitSize, 4096));
-                if (pBlock) {
-                    m_Blocks.Add(pBlock);
-                }
+                m_Blocks.Add(pBlock);
             }
             m_nGrowSize = FX_MAX(nGrowSize, 4096);
         } else if (m_Blocks.GetSize() < 1) {
@@ -407,9 +405,6 @@
         m_Blocks.SetSize(m_Blocks.GetSize() + (FX_INT32)size);
         while (size --) {
             FX_LPBYTE pBlock = FX_Alloc(FX_BYTE, m_nGrowSize);
-            if (!pBlock) {
-                return FALSE;
-            }
             m_Blocks.SetAt(iCount ++, pBlock);
             m_nTotalSize += m_nGrowSize;
         }
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index 5a2a2e5..43a5417 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -39,10 +39,6 @@
             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) {
@@ -197,10 +193,6 @@
     }
     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;
@@ -222,10 +214,6 @@
     }
     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 ++;
@@ -236,9 +224,6 @@
     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;
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index 781b821..2377a6d 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -73,9 +73,6 @@
     FXSYS_assert(usableSize >= nLen);
 
     void* pData = FX_Alloc(FX_BYTE, totalSize);
-    if (!pData) {
-        return NULL;
-    }
     return new (pData) StringData(nLen, usableSize);
 }
 CFX_ByteString::~CFX_ByteString()
diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp
index 7903740..06ba941 100644
--- a/core/src/fxcrt/fx_basic_buffer.cpp
+++ b/core/src/fxcrt/fx_basic_buffer.cpp
@@ -88,10 +88,8 @@
     } else {
         pNewBuffer = FX_Alloc(FX_BYTE, new_size);
     }
-    if (pNewBuffer) {
-        m_pBuffer = pNewBuffer;
-        m_AllocSize = new_size;
-    }
+    m_pBuffer = pNewBuffer;
+    m_AllocSize = new_size;
 }
 void CFX_BinaryBuf::CopyData(const void* pStr, FX_STRSIZE size)
 {
@@ -456,9 +454,6 @@
     }
     if (!m_pBuffer) {
         m_pBuffer = FX_Alloc(FX_BYTE, m_BufSize);
-        if (!m_pBuffer) {
-            return -1;
-        }
     }
     FX_LPBYTE buffer = (FX_LPBYTE)pBuf;
     FX_STRSIZE temp_size = (FX_STRSIZE)size;
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index 8ae44ce..7fca42a 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -413,9 +413,7 @@
     pCompact->m_LenHigh = len / 256;
     pCompact->m_LenLow = len % 256;
     pCompact->m_pBuffer = FX_Alloc(FX_BYTE, len);
-    if (pCompact->m_pBuffer) {
-        FXSYS_memcpy32(pCompact->m_pBuffer, pStr, len);
-    }
+    FXSYS_memcpy32(pCompact->m_pBuffer, pStr, len);
 }
 static CFX_ByteStringC _CompactStringGet(_CompactString* pCompact)
 {
diff --git a/core/src/fxcrt/fx_basic_plex.cpp b/core/src/fxcrt/fx_basic_plex.cpp
index bff5546..78319bd 100644
--- a/core/src/fxcrt/fx_basic_plex.cpp
+++ b/core/src/fxcrt/fx_basic_plex.cpp
@@ -9,9 +9,6 @@
 CFX_Plex* CFX_Plex::Create(CFX_Plex*& pHead, FX_DWORD nMax, FX_DWORD cbElement)
 {
     CFX_Plex* p = (CFX_Plex*)FX_Alloc(FX_BYTE, sizeof(CFX_Plex) + nMax * cbElement);
-    if (!p) {
-        return NULL;
-    }
     p->pNext = pHead;
     pHead = p;
     return p;
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index 3c54ca9..09e64e0 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -34,9 +34,6 @@
     FXSYS_assert(usableLen >= nLen);
 
     void* pData = FX_Alloc(FX_BYTE, iSize.ValueOrDie());
-    if (!pData) {
-        return NULL;
-    }
     return new (pData) StringData(nLen, usableLen);
 }
 CFX_WideString::~CFX_WideString()
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index 4790aee..20e2e1a 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -275,9 +275,6 @@
 FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed)
 {
     FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1);
-    if (!pContext) {
-        return NULL;
-    }
     pContext->mt[0] = dwSeed;
     FX_DWORD &i = pContext->mti;
     FX_LPDWORD pBuf = pContext->mt;
diff --git a/core/src/fxcrt/fxcrt_platforms.cpp b/core/src/fxcrt/fxcrt_platforms.cpp
index d9b9962..942d6a3 100644
--- a/core/src/fxcrt/fxcrt_platforms.cpp
+++ b/core/src/fxcrt/fxcrt_platforms.cpp
@@ -169,9 +169,6 @@
     }
     FX_FILESIZE num = 0;
     FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768);
-    if (!pBuffer) {
-        return FALSE;
-    }
     while (num = src.Read(pBuffer, 32768)) {
         if (dst.Write(pBuffer, num) != num) {
             break;
diff --git a/core/src/fxcrt/fxcrt_posix.cpp b/core/src/fxcrt/fxcrt_posix.cpp
index 2982435..06d92c5 100644
--- a/core/src/fxcrt/fxcrt_posix.cpp
+++ b/core/src/fxcrt/fxcrt_posix.cpp
@@ -165,9 +165,6 @@
     }
     size_t num = 0;
     FX_LPBYTE pBuffer = FX_Alloc(FX_BYTE, 32768);
-    if (!pBuffer) {
-        return FALSE;
-    }
     num = src.Read(pBuffer, 32768);
     while (num) {
         if (dst.Write(pBuffer, num) != num) {
diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h
index 964c794..f0a2485 100644
--- a/core/src/fxcrt/xml_int.h
+++ b/core/src/fxcrt/xml_int.h
@@ -107,9 +107,6 @@
         m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart);
         if (!m_pBuffer) {
             m_pBuffer = FX_Alloc(FX_BYTE, m_dwSize);
-            if (!m_pBuffer) {
-                return FALSE;
-            }
         }
         return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize);
     }
diff --git a/core/src/fxge/agg/agg23/agg_array.h b/core/src/fxge/agg/agg23/agg_array.h
index b3b5f2b..810eb4e 100644
--- a/core/src/fxge/agg/agg23/agg_array.h
+++ b/core/src/fxge/agg/agg23/agg_array.h
@@ -111,12 +111,8 @@
         m_capacity = 0;
     } else if(full_cap > m_capacity) {
         FX_Free(m_array);
-        m_array = 0;
-        m_capacity = 0;
         m_array = FX_Alloc(T, full_cap);
-        if (m_array) {
-            m_capacity = full_cap;
-        }
+        m_capacity = full_cap;
     }
 }
 template<class T>
diff --git a/core/src/fxge/agg/agg23/fx_agg_path_storage.cpp b/core/src/fxge/agg/agg23/fx_agg_path_storage.cpp
index b4b184e..b62d4ba 100644
--- a/core/src/fxge/agg/agg23/fx_agg_path_storage.cpp
+++ b/core/src/fxge/agg/agg23/fx_agg_path_storage.cpp
@@ -71,9 +71,6 @@
         FX_Alloc( FX_FLOAT, block_size * 2 +
                   block_size /
                   (sizeof(FX_FLOAT) / sizeof(unsigned char)));
-    if (!m_coord_blocks[nb]) {
-        return;
-    }
     m_cmd_blocks[nb]  =
         (unsigned char*)(m_coord_blocks[nb] + block_size * 2);
     m_total_blocks++;
diff --git a/core/src/fxge/agg/agg23/fx_agg_rasterizer_scanline_aa.cpp b/core/src/fxge/agg/agg23/fx_agg_rasterizer_scanline_aa.cpp
index 634d10a..1c32d96 100644
--- a/core/src/fxge/agg/agg23/fx_agg_rasterizer_scanline_aa.cpp
+++ b/core/src/fxge/agg/agg23/fx_agg_rasterizer_scanline_aa.cpp
@@ -117,9 +117,6 @@
     if(m_cur_block >= m_num_blocks) {
         if(m_num_blocks >= m_max_blocks) {
             cell_aa** new_cells = FX_Alloc( cell_aa*, m_max_blocks + cell_block_pool);
-            if (!new_cells) {
-                return;
-            }
             if(m_cells) {
                 FXSYS_memcpy32(new_cells, m_cells, m_max_blocks * sizeof(cell_aa*));
                 FX_Free(m_cells);
@@ -128,9 +125,6 @@
             m_max_blocks += cell_block_pool;
         }
         m_cells[m_num_blocks++] = FX_Alloc(cell_aa, cell_block_size);
-        if (!m_cells[m_num_blocks - 1]) {
-            return;
-        }
     }
     m_cur_cell_ptr = m_cells[m_cur_block++];
 }
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index ae72fc5..e385bc9 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -3601,9 +3601,6 @@
             if ((dest_format & 0xff) == 8) {
                 int pal_count = 1 << (src_format & 0xff);
                 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count);
-                if (!gray_pal) {
-                    return;
-                }
                 pDestPalette = (FX_DWORD*)gray_pal;
                 for (int i = 0; i < pal_count; i ++) {
                     FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) : FXARGB_TODIB(pSrcPalette[i]);
@@ -3613,9 +3610,6 @@
             } else {
                 int palsize = 1 << (src_format & 0xff);
                 pDestPalette = FX_Alloc(FX_DWORD, palsize);
-                if (!pDestPalette) {
-                    return;
-                }
                 for (int i = 0; i < palsize; i ++) {
                     FX_DWORD color = isSrcCmyk ? FXCMYK_TODIB(pSrcPalette[i]) : FXARGB_TODIB(pSrcPalette[i]);
                     pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&color, (FX_LPCBYTE)&color, 1);
@@ -3625,9 +3619,6 @@
         } else {
             int pal_count = 1 << (src_format & 0xff);
             FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count);
-            if (!gray_pal) {
-                return;
-            }
             if (pal_count == 2) {
                 gray_pal[0] = 0;
                 gray_pal[1] = 255;
@@ -3641,10 +3632,6 @@
                 pDestPalette = (FX_DWORD*)gray_pal;
             } else {
                 pDestPalette = FX_Alloc(FX_DWORD, pal_count);
-                if (!pDestPalette) {
-                    FX_Free(gray_pal);
-                    return;
-                }
                 for (int i = 0; i < pal_count; i ++) {
                     pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&pDestPalette[i], &gray_pal[i], 1);
                     pDestPalette[i] = isDstCmyk ? FXCMYK_TODIB(pDestPalette[i]) : FXARGB_TODIB(pDestPalette[i]);
@@ -3657,9 +3644,6 @@
             if ((dest_format & 0xff) == 8) {
                 int pal_count = 1 << (src_format & 0xff);
                 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count);
-                if (!gray_pal) {
-                    return;
-                }
                 pDestPalette = (FX_DWORD*)gray_pal;
                 if (isSrcCmyk) {
                     for (int i = 0; i < pal_count; i ++) {
@@ -3677,9 +3661,6 @@
             } else {
                 int palsize = 1 << (src_format & 0xff);
                 pDestPalette = FX_Alloc(FX_DWORD, palsize);
-                if (!pDestPalette) {
-                    return;
-                }
                 if (isDstCmyk == isSrcCmyk) {
                     FXSYS_memcpy32(pDestPalette, pSrcPalette, palsize * sizeof(FX_DWORD));
                 } else {
@@ -3696,9 +3677,6 @@
             if ((dest_format & 0xff) == 8) {
                 int pal_count = 1 << (src_format & 0xff);
                 FX_LPBYTE gray_pal = FX_Alloc(FX_BYTE, pal_count);
-                if (!gray_pal) {
-                    return;
-                }
                 if (pal_count == 2) {
                     gray_pal[0] = 0;
                     gray_pal[1] = 255;
@@ -3711,9 +3689,6 @@
             } else {
                 int palsize = 1 << (src_format & 0xff);
                 pDestPalette = FX_Alloc(FX_DWORD, palsize);
-                if (!pDestPalette) {
-                    return;
-                }
                 if (palsize == 2) {
                     pDestPalette[0] = isSrcCmyk ? 255 : 0xff000000;
                     pDestPalette[1] = isSrcCmyk ? 0 : 0xffffffff;
@@ -4463,25 +4438,13 @@
     }
     if (m_bVertical) {
         m_pScanlineV = FX_Alloc(FX_BYTE, m_pBitmap->GetBPP() / 8 * width + 4);
-        if (!m_pScanlineV) {
-            return FALSE;
-        }
         m_pClipScanV = FX_Alloc(FX_BYTE, m_pBitmap->GetHeight());
-        if (!m_pClipScanV) {
-            return FALSE;
-        }
         if (m_pBitmap->m_pAlphaMask) {
             m_pScanlineAlphaV = FX_Alloc(FX_BYTE, width + 4);
-            if (!m_pScanlineAlphaV) {
-                return FALSE;
-            }
         }
     }
     if (m_BitmapAlpha < 255) {
         m_pAddClipScan = FX_Alloc(FX_BYTE, m_bVertical ? m_pBitmap->GetHeight() : m_pBitmap->GetWidth());
-        if (!m_pAddClipScan) {
-            return FALSE;
-        }
     }
     return TRUE;
 }
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 4a8befe..dacc43d 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -236,9 +236,6 @@
         FX_Free(m_pPalette);
     }
     m_pPalette = FX_Alloc(FX_DWORD, 256);
-    if (!m_pPalette) {
-        return FALSE;
-    }
     int bpp    = pBitmap->GetBPP() / 8;
     int width  = pBitmap->GetWidth();
     int height = pBitmap->GetHeight();
@@ -251,13 +248,7 @@
         m_aLut = NULL;
     }
     m_cLut = FX_Alloc(FX_DWORD, 4096);
-    if (!m_cLut) {
-        return FALSE;
-    }
     m_aLut = FX_Alloc(FX_DWORD, 4096);
-    if (!m_aLut) {
-        return FALSE;
-    }
     int row, col;
     m_lut = 0;
     for (row = 0; row < height; row++) {
@@ -868,9 +859,6 @@
                     return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
                 }
                 d_pal = FX_Alloc(FX_DWORD, 256);
-                if (!d_pal) {
-                    return FALSE;
-                }
                 if (((src_format & 0xff) == 1 || (src_format & 0xff) == 8) && pSrcBitmap->GetPalette()) {
                     return _ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height, pSrcBitmap, src_left, src_top, d_pal, pIccTransform);
                 } else if ((src_format & 0xff) >= 24) {
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index 7c40171..b486def 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -796,14 +796,8 @@
     }
     size *= m_DestBPP;
     m_pScanline = FX_Alloc(FX_BYTE, (size / 8 + 3) / 4 * 4);
-    if (!m_pScanline) {
-        return FALSE;
-    }
     if (m_pSource->m_pAlphaMask) {
         m_pMaskScanline = FX_Alloc(FX_BYTE, (m_ClipRect.Width() + 3) / 4 * 4);
-        if (!m_pMaskScanline) {
-            return FALSE;
-        }
     }
     if (m_pSource->GetWidth() * m_pSource->GetHeight() < MAX_PROGRESSIVE_STRETCH_PIXELS) {
         ContinueQuickStretch(NULL);
diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp
index a54c9ab..f55b2f5 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -85,12 +85,12 @@
         int oomlimit = _MAX_OOM_LIMIT_;
         if (oomlimit >= 0 && size >= oomlimit) {
             m_pBuffer = FX_TryAlloc(FX_BYTE, size);
+            if (m_pBuffer == NULL) {
+                return FALSE;
+            }
         } else {
             m_pBuffer = FX_Alloc(FX_BYTE, size);
         }
-        if (m_pBuffer == NULL) {
-            return FALSE;
-        }
     }
     m_Width = width;
     m_Height = height;
@@ -202,9 +202,6 @@
     }
     if (GetBPP() == 1) {
         m_pPalette = FX_Alloc(FX_DWORD, 2);
-        if (!m_pPalette) {
-            return;
-        }
         if(IsCmykImage()) {
             m_pPalette[0] = 0xff;
             m_pPalette[1] = 0;
@@ -214,9 +211,6 @@
         }
     } else if (GetBPP() == 8) {
         m_pPalette = FX_Alloc(FX_DWORD, 256);
-        if (!m_pPalette) {
-            return;
-        }
         if(IsCmykImage()) {
             for (int i = 0; i < 256; i ++) {
                 m_pPalette[i] = 0xff - i;
@@ -531,9 +525,6 @@
         if (m_pPalette == NULL) {
             m_pPalette = FX_Alloc(FX_DWORD, pal_size);
         }
-        if (!m_pPalette) {
-            return;
-        }
         if (pal_size > size) {
             pal_size = size;
         }
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index 104a239..1896218 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -104,9 +104,6 @@
 FX_BOOL _LoadFile(FXFT_Library library, FXFT_Face* Face, IFX_FileRead* pFile, FXFT_Stream* stream)
 {
     FXFT_Stream stream1 = (FXFT_Stream)FX_Alloc(FX_BYTE, sizeof (FXFT_StreamRec));
-    if (!stream1) {
-        return FALSE;
-    }
     stream1->base = NULL;
     stream1->size = (unsigned long)pFile->GetSize();
     stream1->pos = 0;
@@ -177,9 +174,6 @@
 FX_BOOL CFX_Font::LoadEmbedded(FX_LPCBYTE data, FX_DWORD size)
 {
     m_pFontDataAllocation = FX_Alloc(FX_BYTE, size);
-    if (!m_pFontDataAllocation) {
-        return FALSE;
-    }
     FXSYS_memcpy32(m_pFontDataAllocation, data, size);
     m_Face = FT_LoadFont((FX_LPBYTE)m_pFontDataAllocation, size);
     m_pFontData = (FX_LPBYTE)m_pFontDataAllocation;
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index f058f03..74f97d1 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -564,9 +564,6 @@
     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);
@@ -1209,21 +1206,15 @@
         face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum, ttc_size - font_size, pFontData);
         if (face == NULL) {
             pFontData = FX_Alloc(FX_BYTE, ttc_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);
-            }
+            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));
         }
@@ -1380,10 +1371,6 @@
         }
         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);
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index b96a2f1..51d5908 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -4,8 +4,10 @@
  
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
+#include "../../../../third_party/base/numerics/safe_math.h"
 #include "../../../include/fxcrt/fx_basic.h"
 #include "../../../include/fxge/fx_ge.h"
+
 CFX_ClipRgn::CFX_ClipRgn(int width, int height)
 {
     m_Type = RectI;
@@ -120,7 +122,7 @@
         FX_Free(m_pPoints);
     }
 }
-FX_BOOL CFX_PathData::SetPointCount(int nPoints)
+void CFX_PathData::SetPointCount(int nPoints)
 {
     m_PointCount = nPoints;
     if (m_AllocCount < nPoints) {
@@ -129,20 +131,13 @@
             m_pPoints = NULL;
         }
         m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints);
-        if (!m_pPoints) {
-            return FALSE;
-        }
         m_AllocCount = nPoints;
     }
-    return TRUE;
 }
-FX_BOOL CFX_PathData::AllocPointCount(int nPoints)
+void CFX_PathData::AllocPointCount(int nPoints)
 {
     if (m_AllocCount < nPoints) {
         FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints);
-        if (!pNewBuf) {
-            return FALSE;
-        }
         if (m_PointCount) {
             FXSYS_memcpy32(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT));
         }
@@ -152,16 +147,11 @@
         m_pPoints = pNewBuf;
         m_AllocCount = nPoints;
     }
-    return TRUE;
 }
 CFX_PathData::CFX_PathData(const CFX_PathData& src)
 {
-    m_pPoints = NULL;
     m_PointCount = m_AllocCount = src.m_PointCount;
     m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount);
-    if (!m_pPoints) {
-        return;
-    }
     FXSYS_memcpy32(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
 }
 void CFX_PathData::TrimPoints(int nPoints)
@@ -171,29 +161,24 @@
     }
     SetPointCount(nPoints);
 }
-FX_BOOL CFX_PathData::AddPointCount(int addPoints)
+void CFX_PathData::AddPointCount(int addPoints)
 {
-    int new_count = m_PointCount + addPoints;
-    if (!AllocPointCount(new_count)) {
-        return FALSE;
-    }
+    pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount;
+    safe_new_count += addPoints;
+    int new_count = safe_new_count.ValueOrDie();
+    AllocPointCount(new_count);
     m_PointCount = new_count;
-    return TRUE;
 }
-FX_BOOL CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix)
+void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_AffineMatrix* pMatrix)
 {
     int old_count = m_PointCount;
-    if (!AddPointCount(pSrc->m_PointCount)) {
-        return FALSE;
-    }
+    AddPointCount(pSrc->m_PointCount);
     FXSYS_memcpy32(m_pPoints + old_count, pSrc->m_pPoints, pSrc->m_PointCount * sizeof(FX_PATHPOINT));
-    if (pMatrix == NULL) {
-        return TRUE;
+    if (pMatrix) {
+        for (int i = 0; i < pSrc->m_PointCount; i ++) {
+            pMatrix->Transform(m_pPoints[old_count + i].m_PointX, m_pPoints[old_count + i].m_PointY);
+        }
     }
-    for (int i = 0; i < pSrc->m_PointCount; i ++) {
-        pMatrix->Transform(m_pPoints[old_count + i].m_PointX, m_pPoints[old_count + i].m_PointY);
-    }
-    return TRUE;
 }
 void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag)
 {
@@ -202,12 +187,10 @@
     m_pPoints[index].m_PointY = y;
     m_pPoints[index].m_Flag = flag;
 }
-FX_BOOL CFX_PathData::AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
+void CFX_PathData::AppendRect(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
 {
     int old_count = m_PointCount;
-    if (!AddPointCount(5)) {
-        return FALSE;
-    }
+    AddPointCount(5);
     FX_PATHPOINT* pPoints = m_pPoints + old_count;
     pPoints[0].m_PointX = pPoints[1].m_PointX = pPoints[4].m_PointX = left;
     pPoints[2].m_PointX = pPoints[3].m_PointX = right;
@@ -216,7 +199,6 @@
     pPoints[0].m_Flag = FXPT_MOVETO;
     pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO;
     pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE;
-    return TRUE;
 }
 CFX_FloatRect CFX_PathData::GetBoundingBox() const
 {
@@ -590,13 +572,10 @@
     }
     return TRUE;
 }
-FX_BOOL CFX_PathData::Copy(const CFX_PathData &src)
+void CFX_PathData::Copy(const CFX_PathData &src)
 {
-    if (!SetPointCount(src.m_PointCount)) {
-        return FALSE;
-    }
+    SetPointCount(src.m_PointCount);
     FXSYS_memcpy32(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
-    return TRUE;
 }
 CFX_GraphStateData::CFX_GraphStateData()
 {
@@ -627,9 +606,6 @@
     m_LineWidth = src.m_LineWidth;
     if (m_DashCount) {
         m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount);
-        if (!m_DashArray) {
-            return;
-        }
         FXSYS_memcpy32(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT));
     }
 }
diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp
index ad57211..e81b6bf 100644
--- a/core/src/fxge/ge/fx_ge_ps.cpp
+++ b/core/src/fxge/ge/fx_ge_ps.cpp
@@ -349,9 +349,6 @@
         int pitch = (width + 7) / 8;
         FX_DWORD src_size = height * pitch;
         FX_LPBYTE src_buf = FX_Alloc(FX_BYTE, src_size);
-        if (!src_buf) {
-            return FALSE;
-        }
         for (int row = 0; row < height; row ++) {
             FX_LPCBYTE src_scan = pSource->GetScanline(row);
             FXSYS_memcpy32(src_buf + row * pitch, src_scan, pitch);
@@ -425,13 +422,6 @@
             int src_pitch = width * Bpp;
             output_size = height * src_pitch;
             output_buf = FX_Alloc(FX_BYTE, output_size);
-            if (!output_buf) {
-                if (pConverted != pSource) {
-                    delete pConverted;
-                    pConverted = NULL;
-                }
-                return FALSE;
-            }
             for (int row = 0; row < height; row ++) {
                 FX_LPCBYTE src_scan = pConverted->GetScanline(row);
                 FX_LPBYTE dest_scan = output_buf + row * src_pitch;
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index 21eebb7..f6d2fa5 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -203,9 +203,6 @@
     CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
     FX_FONTCACHE_DEFINE(pCache, pFont);
     FXTEXT_GLYPHPOS* pGlyphAndPos = FX_Alloc(FXTEXT_GLYPHPOS, nChars);
-    if (!pGlyphAndPos) {
-        return FALSE;
-    }
     int iChar;
     deviceCtm = char2device;
     CFX_AffineMatrix matrixCTM = GetCTM();
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 00baa2b..0717fb1 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -655,9 +655,6 @@
     FX_DWORD* pDash = NULL;
     if (pGraphState->m_DashCount) {
         pDash = FX_Alloc(FX_DWORD, pGraphState->m_DashCount);
-        if (!pDash) {
-            return NULL;
-        }
         for (int i = 0; i < pGraphState->m_DashCount; i ++) {
             pDash[i] = FXSYS_round(pMatrix ? pMatrix->TransformDistance(pGraphState->m_DashArray[i]) : pGraphState->m_DashArray[i]);
             if (pDash[i] < 1) {
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index ec523c3..46abdb3 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -69,12 +69,6 @@
     FXSYS_memcpy32(pBitmap->GetBuffer(), pData, pitch * height);
     if (bBottomUp) {
         FX_LPBYTE temp_buf = FX_Alloc(FX_BYTE, pitch);
-        if (!temp_buf) {
-            if (pBitmap) {
-                delete pBitmap;
-            }
-            return NULL;
-        }
         int top = 0, bottom = height - 1;
         while (top < bottom) {
             FXSYS_memcpy32(temp_buf, pBitmap->GetBuffer() + top * pitch, pitch);
@@ -203,13 +197,6 @@
             size += sizeof (FX_DWORD) * 254;
         }
         BITMAPINFO* pbmih = (BITMAPINFO*)FX_Alloc(FX_BYTE, size);
-        if (!pbmih) {
-            delete pDIBitmap;
-            if (bCreatedDC) {
-                DeleteDC(hDC);
-            }
-            return NULL;
-        }
         pbmih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
         pbmih->bmiHeader.biBitCount = bmih.biBitCount;
         pbmih->bmiHeader.biCompression = BI_RGB;
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index 49c3f2b..67aa162 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -766,9 +766,6 @@
     CallFunc(GdipSetPenLineJoin)(pPen, lineJoin);
     if(pGraphState->m_DashCount) {
         FX_FLOAT* pDashArray = FX_Alloc(FX_FLOAT, pGraphState->m_DashCount + pGraphState->m_DashCount % 2);
-        if (!pDashArray) {
-            return NULL;
-        }
         int nCount = 0;
         FX_FLOAT on_leftover = 0, off_leftover = 0;
         for (int i = 0; i < pGraphState->m_DashCount; i += 2) {
@@ -870,14 +867,7 @@
         CallFunc(GdipSetWorldTransform)(pGraphics, pMatrix);
     }
     PointF *points = FX_Alloc(PointF, nPoints);
-    if (!points) {
-        return FALSE;
-    }
     BYTE * types  = FX_Alloc(BYTE, nPoints);
-    if (!types) {
-        FX_Free(points);
-        return FALSE;
-    }
     int nSubPathes = 0;
     FX_BOOL bSubClose = FALSE;
     int pos_subclose = 0;
@@ -1192,12 +1182,6 @@
         dest_pixel_format = PixelFormat32bppARGB;
     }
     LPBYTE buf = FX_Alloc(BYTE, info_size);
-    if (!buf) {
-        if (pStream) {
-            pStream->Release();
-        }
-        return NULL;
-    }
     BITMAPINFOHEADER* pbmih = (BITMAPINFOHEADER*)buf;
     pbmih->biBitCount = bpp;
     pbmih->biCompression = BI_RGB;
@@ -1206,12 +1190,6 @@
     pbmih->biWidth = width;
     Rect rect(0, 0, width, height);
     BitmapData* pBitmapData = FX_Alloc(BitmapData, 1);
-    if (!pBitmapData) {
-        if (pStream) {
-            pStream->Release();
-        }
-        return NULL;
-    }
     CallFunc(GdipBitmapLockBits)(pBitmap, &rect, ImageLockModeRead,
                                  dest_pixel_format, pBitmapData);
     if (pixel_format == PixelFormat1bppIndexed || pixel_format == PixelFormat8bppIndexed) {
@@ -1230,12 +1208,6 @@
         }
     }
     PREVIEW3_DIBITMAP* pInfo = FX_Alloc(PREVIEW3_DIBITMAP, 1);
-    if (!pInfo) {
-        if (pStream) {
-            pStream->Release();
-        }
-        return NULL;
-    }
     pInfo->pbmi = (BITMAPINFO*)buf;
     pInfo->pScan0 = (LPBYTE)pBitmapData->Scan0;
     pInfo->Stride = pBitmapData->Stride;
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 7dc48a1..670622a 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -295,9 +295,6 @@
         ret = ::GetRegionData(hRgn, 0, NULL);
         if (ret) {
             RGNDATA* pData = (RGNDATA*)FX_Alloc(FX_BYTE, ret);
-            if (!pData) {
-                return FALSE;
-            }
             ret = ::GetRegionData(hRgn, ret, pData);
             if (ret) {
                 CFX_PathData path;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 9ab6184..0cbc4ba 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -2352,13 +2352,10 @@
   			if(i != pFields->GetCount()-1)
   				fdfEncodedData = fdfEncodedData<<"&";
  		}
-		
+
 		nBufSize = fdfEncodedData.GetLength();
 		pBuf = FX_Alloc(FX_BYTE, nBufSize);
-		if(!pBuf)
-			return FALSE;
 		FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
- 		
  	}
 	return TRUE;
 }
diff --git a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
index f704a67..678da68 100644
--- a/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
+++ b/fpdfsdk/src/pdfwindow/PWL_Edit.cpp
@@ -426,17 +426,15 @@
 				gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
 
 				CFX_PathData path;
-				if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
-					return;
-				}
-				
+				path.SetPointCount(nCharArraySafe.ValueOrDie());
+
 				for (FX_INT32 i=0; i<nCharArray-1; i++)
-				{					
-					path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1), 
+				{
+					path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
 						rcClient.bottom, FXPT_MOVETO);
 					path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
-						rcClient.top, FXPT_LINETO);											
-				}			
+						rcClient.top, FXPT_LINETO);
+				}
 				if (path.GetPointCount() > 0)
 					pDevice->DrawPath(&path, pUser2Device, &gsd,0,  
 						CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
@@ -453,19 +451,17 @@
 				gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
 
 				CFX_PathData path;
-				if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
-					return;
-				}
-				
+				path.SetPointCount(nCharArraySafe.ValueOrDie());
+
 				for (FX_INT32 i=0; i<nCharArray-1; i++)
-				{					
-					path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1), 
+				{
+					path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
 						rcClient.bottom, FXPT_MOVETO);
 					path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
-						rcClient.top, FXPT_LINETO);											
-				}		
+						rcClient.top, FXPT_LINETO);
+				}
 				if (path.GetPointCount() > 0)
-					pDevice->DrawPath(&path, pUser2Device, &gsd,0,  
+					pDevice->DrawPath(&path, pUser2Device, &gsd,0,
 						CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
 			}
 			break;