3136: Fix some asan issues r=Jupeyy a=def-



Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
bors[bot] 2020-10-22 15:26:41 +00:00 committed by GitHub
commit 2ba4d5d6cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -3574,9 +3574,9 @@ const char *CServer::GetAnnouncementLine(char const *pFileName)
std::vector<char *> v;
char *pLine;
CLineReader *lr = new CLineReader();
lr->Init(File);
while((pLine = lr->Get()))
CLineReader lr;
lr.Init(File);
while((pLine = lr.Get()))
if(str_length(pLine))
if(pLine[0] != '#')
v.push_back(pLine);

View file

@ -591,6 +591,12 @@ CDataFileWriter::~CDataFileWriter()
{
free(m_pItemTypes);
m_pItemTypes = 0;
for(int i = 0; i < m_NumItems; i++)
if(m_pItems[i].m_pData)
free(m_pItems[i].m_pData);
for(int i = 0; i < m_NumDatas; ++i)
if(m_pDatas[i].m_pCompressedData)
free(m_pDatas[i].m_pCompressedData);
free(m_pItems);
m_pItems = 0;
free(m_pDatas);
@ -895,9 +901,15 @@ int CDataFileWriter::Finish()
// free data
for(int i = 0; i < m_NumItems; i++)
{
free(m_pItems[i].m_pData);
m_pItems[i].m_pData = 0;
}
for(int i = 0; i < m_NumDatas; ++i)
{
free(m_pDatas[i].m_pCompressedData);
m_pDatas[i].m_pCompressedData = 0;
}
io_close(m_File);
m_File = 0;