mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Add bound check in datafile.cpp anywhere m_ppDataPtrs is accessed as an array. Should fix #2073
This commit is contained in:
parent
d25869626a
commit
e086f4b35b
|
@ -249,6 +249,9 @@ void *CDataFileReader::GetDataImpl(int Index, int Swap)
|
|||
{
|
||||
if(!m_pDataFile) { return 0; }
|
||||
|
||||
if(Index < 0 || Index >= m_pDataFile->m_Header.m_NumRawData)
|
||||
return 0;
|
||||
|
||||
// load it if needed
|
||||
if(!m_pDataFile->m_ppDataPtrs[Index])
|
||||
{
|
||||
|
@ -312,6 +315,9 @@ void *CDataFileReader::GetDataSwapped(int Index)
|
|||
|
||||
void CDataFileReader::ReplaceData(int Index, char *pData)
|
||||
{
|
||||
if(Index < 0 || Index >= m_pDataFile->m_Header.m_NumRawData)
|
||||
return;
|
||||
|
||||
// make sure the data has been loaded
|
||||
GetDataImpl(Index, 0);
|
||||
|
||||
|
@ -321,10 +327,9 @@ void CDataFileReader::ReplaceData(int Index, char *pData)
|
|||
|
||||
void CDataFileReader::UnloadData(int Index)
|
||||
{
|
||||
if(Index < 0)
|
||||
if(Index < 0 || Index >= m_pDataFile->m_Header.m_NumRawData)
|
||||
return;
|
||||
|
||||
//
|
||||
mem_free(m_pDataFile->m_ppDataPtrs[Index]);
|
||||
m_pDataFile->m_ppDataPtrs[Index] = 0x0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue