mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Fix possible integer overflows using mem_*
functions
This commit is contained in:
parent
18cfbb53f9
commit
ec7f5560a3
|
@ -540,7 +540,7 @@ class CTextRender : public IEngineTextRender
|
|||
if(Width > 0 && Height > 0)
|
||||
{
|
||||
// prepare glyph data
|
||||
mem_zero(ms_aGlyphData, Width * Height);
|
||||
mem_zero(ms_aGlyphData, (size_t)Width * Height);
|
||||
|
||||
for(py = 0; py < pBitmap->rows; py++)
|
||||
for(px = 0; px < pBitmap->width; px++)
|
||||
|
|
|
@ -511,8 +511,9 @@ bool CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Stora
|
|||
|
||||
// copy image data
|
||||
void *pData = DataFile.GetData(pItem->m_ImageData);
|
||||
pImg->m_pData = malloc((size_t)pImg->m_Width * pImg->m_Height * 4);
|
||||
mem_copy(pImg->m_pData, pData, pImg->m_Width * pImg->m_Height * 4);
|
||||
const size_t DataSize = (size_t)pImg->m_Width * pImg->m_Height * 4;
|
||||
pImg->m_pData = malloc(DataSize);
|
||||
mem_copy(pImg->m_pData, pData, DataSize);
|
||||
int TextureLoadFlag = m_pEditor->Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE;
|
||||
if(pImg->m_Width % 16 != 0 || pImg->m_Height % 16 != 0)
|
||||
TextureLoadFlag = 0;
|
||||
|
|
|
@ -250,7 +250,7 @@ int main(int argc, const char **argv)
|
|||
}
|
||||
else if(aImageFlags[ImageIndex] == 0)
|
||||
{
|
||||
mem_zero(pImgBuff, Width * Height * 4);
|
||||
mem_zero(pImgBuff, (size_t)Width * Height * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue