diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:48:00 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:48:00 -0700 |
commit | eb6527763171cdb4b0fbfea5a20d691f4d67b660 (patch) | |
tree | 7781d0fb716b95696b9f411037508244f4cfc28a /core/src/fxcodec | |
parent | 59f4b44d1fbb259967ea518e0bf5fa76b0cc9767 (diff) | |
download | pdfium-eb6527763171cdb4b0fbfea5a20d691f4d67b660.tar.xz |
Remove FX_Alloc() null checks now that it can't return NULL.
This permits some functions to become void's since
they, in turn, can't fail.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1142713005
Diffstat (limited to 'core/src/fxcodec')
-rw-r--r-- | core/src/fxcodec/codec/fx_codec.cpp | 3 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_fax.cpp | 12 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_flate.cpp | 42 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_icc.cpp | 6 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jbig.cpp | 6 | ||||
-rw-r--r-- | core/src/fxcodec/codec/fx_codec_jpx_opj.cpp | 6 |
6 files changed, 3 insertions, 72 deletions
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp index e8aad711f3..c325cccdd4 100644 --- a/core/src/fxcodec/codec/fx_codec.cpp +++ b/core/src/fxcodec/codec/fx_codec.cpp @@ -333,9 +333,6 @@ FX_BOOL CCodec_RLScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, 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 33e89e4f92..dc2ee2aacd 100644 --- a/core/src/fxcodec/codec/fx_codec_fax.cpp +++ b/core/src/fxcodec/codec/fx_codec_fax.cpp @@ -622,13 +622,7 @@ FX_BOOL CCodec_FaxDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int wid 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 @@ extern "C" { 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 @@ CCodec_FaxEncoder::CCodec_FaxEncoder(FX_LPCBYTE src_buf, int width, int height, 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 4d43cc554b..7a19e8b855 100644 --- a/core/src/fxcodec/codec/fx_codec_flate.cpp +++ b/core/src/fxcodec/codec/fx_codec_flate.cpp @@ -583,8 +583,8 @@ class CCodec_FlateScanlineDecoder : public CCodec_ScanlineDecoder 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 @@ CCodec_FlateScanlineDecoder::~CCodec_FlateScanlineDecoder() 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 @@ FX_BOOL CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_siz 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 @@ FX_BOOL CCodec_FlateScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_siz 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 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig 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 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig // |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 @@ static void FlateUncompress(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_DWORD orig 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 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, const FX_BYTE* src_b { 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_BOOL CCodec_FlateModule::Encode(const FX_BYTE* src_buf, FX_DWORD src_size, } 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 @@ FX_BOOL CCodec_FlateModule::Encode(FX_LPCBYTE src_buf, FX_DWORD src_size, FX_LPB { 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 a984fecc30..26b4c1adfc 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 CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) 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 @@ FX_LPVOID CCodec_IccModule::CreateTransform(ICodec_IccModule::IccParam* pInputPa 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 278d9cbcf6..8fcd9f4711 100644 --- a/core/src/fxcodec/codec/fx_codec_jbig.cpp +++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp @@ -53,9 +53,6 @@ FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr, 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 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context, IFX_FileRead 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 3546f574f9..1a1616c0a1 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 @@ FX_BOOL CJPX_Decoder::Decode(FX_LPBYTE dest_buf, int pitch, FX_BOOL bTranslateCo } 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; |