diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.cpp | 6 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_Context.cpp | 4 | ||||
-rw-r--r-- | core/fxcrt/fx_memory.h | 4 |
3 files changed, 2 insertions, 12 deletions
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.cpp b/core/fxcodec/codec/ccodec_progressivedecoder.cpp index 27a2494baf..0e6014595e 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.cpp +++ b/core/fxcodec/codec/ccodec_progressivedecoder.cpp @@ -805,7 +805,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpStartDecode( GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); m_ScanlineSize = FxAlignToBoundary<4>(m_SrcWidth * m_SrcComponents); m_pDecodeBuf.reset(FX_Alloc(uint8_t, m_ScanlineSize)); - memset(m_pDecodeBuf.get(), 0, m_ScanlineSize); m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, m_clipBox.Width()); m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); @@ -903,7 +902,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::GifStartDecode( GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); int scanline_size = FxAlignToBoundary<4>(m_SrcWidth); m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size)); - memset(m_pDecodeBuf.get(), 0, scanline_size); m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, m_clipBox.Width()); m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); @@ -1110,7 +1108,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::JpegStartDecode( int scanline_size = (m_SrcWidth + down_scale - 1) / down_scale; scanline_size = FxAlignToBoundary<4>(scanline_size * m_SrcComponents); m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size)); - memset(m_pDecodeBuf.get(), 0, scanline_size); m_WeightHorz.Calc(m_sizeX, 0, m_sizeX, m_clipBox.Width(), 0, m_clipBox.Width()); m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); @@ -1272,7 +1269,6 @@ bool CCodec_ProgressiveDecoder::PngDetectImageTypeInBuffer( } if (m_pSrcBuf && input_size > m_SrcSize) { m_pSrcBuf.reset(FX_Alloc(uint8_t, input_size)); - memset(m_pSrcBuf.get(), 0, input_size); m_SrcSize = input_size; } bResult = m_pFile->ReadBlock(m_pSrcBuf.get(), m_offSet, input_size); @@ -1334,7 +1330,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::PngStartDecode( GetTransMethod(m_pDeviceBitmap->GetFormat(), m_SrcFormat); int scanline_size = FxAlignToBoundary<4>(m_SrcWidth * m_SrcComponents); m_pDecodeBuf.reset(FX_Alloc(uint8_t, scanline_size)); - memset(m_pDecodeBuf.get(), 0, scanline_size); m_WeightHorzOO.Calc(m_sizeX, m_clipBox.Width()); m_WeightVert.Calc(m_sizeY, m_clipBox.Height()); m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE; @@ -1360,7 +1355,6 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::PngContinueDecode() { } if (m_pSrcBuf && input_size > m_SrcSize) { m_pSrcBuf.reset(FX_Alloc(uint8_t, input_size)); - memset(m_pSrcBuf.get(), 0, input_size); m_SrcSize = input_size; } bool bResult = m_pFile->ReadBlock(m_pSrcBuf.get(), m_offSet, input_size); diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index 4656bfa084..3a868c1486 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -817,7 +817,6 @@ JBig2_Result CJBig2_Context::ParseTextRegion(CJBig2_Segment* pSegment) { if (pTRD->SBREFINE == 1) { const size_t size = GetRefAggContextSize(pTRD->SBRTEMPLATE); grContext.reset(FX_Alloc(JBig2ArithCtx, size)); - memset(grContext.get(), 0, sizeof(JBig2ArithCtx) * size); } if (pTRD->SBHUFF == 0) { auto pArithDecoder = @@ -871,7 +870,6 @@ JBig2_Result CJBig2_Context::ParsePatternDict(CJBig2_Segment* pSegment, const size_t size = GetHuffContextSize(pPDD->HDTEMPLATE); std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> gbContext( FX_Alloc(JBig2ArithCtx, size)); - memset(gbContext.get(), 0, sizeof(JBig2ArithCtx) * size); auto pArithDecoder = pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get()); pSegment->m_PatternDict = @@ -940,7 +938,6 @@ JBig2_Result CJBig2_Context::ParseHalftoneRegion(CJBig2_Segment* pSegment, const size_t size = GetHuffContextSize(pHRD->HTEMPLATE); std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> gbContext( FX_Alloc(JBig2ArithCtx, size)); - memset(gbContext.get(), 0, sizeof(JBig2ArithCtx) * size); auto pArithDecoder = pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get()); pSegment->m_Image = @@ -1123,7 +1120,6 @@ JBig2_Result CJBig2_Context::ParseGenericRefinementRegion( const size_t size = GetRefAggContextSize(pGRRD->GRTEMPLATE); std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> grContext( FX_Alloc(JBig2ArithCtx, size)); - memset(grContext.get(), 0, sizeof(JBig2ArithCtx) * size); auto pArithDecoder = pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get()); pSegment->m_nResultType = JBIG2_IMAGE_POINTER; pSegment->m_Image = pGRRD->Decode(pArithDecoder.get(), grContext.get()); diff --git a/core/fxcrt/fx_memory.h b/core/fxcrt/fx_memory.h index b39911269b..5596bceabe 100644 --- a/core/fxcrt/fx_memory.h +++ b/core/fxcrt/fx_memory.h @@ -88,7 +88,7 @@ inline void* FX_ReallocOrDie(void* ptr, return result; } -// These never return nullptr. +// These never return nullptr, and must return cleared memory. #define FX_Alloc(type, size) \ static_cast<type*>(FX_AllocOrDie(size, sizeof(type))) #define FX_Alloc2D(type, w, h) \ @@ -96,7 +96,7 @@ inline void* FX_ReallocOrDie(void* ptr, #define FX_Realloc(type, ptr, size) \ static_cast<type*>(FX_ReallocOrDie(ptr, size, sizeof(type))) -// May return nullptr. +// May return nullptr, but returns cleared memory otherwise. #define FX_TryAlloc(type, size) \ static_cast<type*>(FX_SafeAlloc(size, sizeof(type))) #define FX_TryRealloc(type, ptr, size) \ |