diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:56:52 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-05-19 14:56:52 -0700 |
commit | bf4aa2cc93a67826247e887b2ba26a1b965eb616 (patch) | |
tree | a1d6336676d6d70467a7fb94aa0e625b1dbc8c25 /core/src/fpdfapi/fpdf_edit | |
parent | eb6527763171cdb4b0fbfea5a20d691f4d67b660 (diff) | |
download | pdfium-bf4aa2cc93a67826247e887b2ba26a1b965eb616.tar.xz |
Revert "Remove FX_Alloc() null checks now that it can't return NULL."
This reverts commit eb6527763171cdb4b0fbfea5a20d691f4d67b660.
Reason for revert: broke javascript tests.
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1145843005
Diffstat (limited to 'core/src/fpdfapi/fpdf_edit')
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 3 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp | 18 |
2 files changed, 15 insertions, 6 deletions
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 3abbcee046..0886d3ff53 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -415,6 +415,9 @@ FX_BOOL CPDF_Encryptor::Initialize(CPDF_CryptoHandler* pHandler, int objnum, FX_ } 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 a5a91ebc53..1328fcdf96 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp @@ -71,11 +71,17 @@ void CPDF_Image::SetJpegImage(IFX_FileRead *pFile) 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); @@ -217,8 +223,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F } else if (pMaskBitmap->GetFormat() == FXDIB_1bppMask) { _JBIG2EncodeBitmap(pMaskDict, pMaskBitmap, m_pDocument, mask_buf, mask_size, TRUE); } else { - mask_buf = FX_Alloc2D(FX_BYTE, maskHeight, maskWidth); - mask_size = maskHeight * maskWidth; // Safe since checked alloc returned. + mask_size = maskHeight * maskWidth; + mask_buf = FX_Alloc(FX_BYTE, mask_size); for (FX_INT32 a = 0; a < maskHeight; a ++) { FXSYS_memcpy32(mask_buf + a * maskWidth, pMaskBitmap->GetScanline(a), maskWidth); } @@ -300,8 +306,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F } } else if (opType == 1) { if (!bStream) { - dest_buf = FX_Alloc2D(FX_BYTE, dest_pitch, BitmapHeight); - dest_size = dest_pitch * BitmapHeight; // Safe since checked alloc returned. + dest_size = dest_pitch * BitmapHeight; + dest_buf = FX_Alloc(FX_BYTE, dest_size); } FX_LPBYTE pDest = dest_buf; for (FX_INT32 i = 0; i < BitmapHeight; i ++) { @@ -315,8 +321,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, FX_INT32 iCompress, IFX_F } } else if (opType == 2) { if (!bStream) { - dest_buf = FX_Alloc2D(FX_BYTE, dest_pitch, BitmapHeight); - dest_size = dest_pitch * BitmapHeight; // Safe since checked alloc returned. + dest_size = dest_pitch * BitmapHeight; + dest_buf = FX_Alloc(FX_BYTE, dest_size); } else { dest_buf = FX_Alloc(FX_BYTE, dest_pitch); } |