Skip to content

Commit 668f7c6

Browse files
committed
fix(cmips): cleaner handling of the freeing of miplevels
1 parent 4edb955 commit 668f7c6

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

cmp_framework/common/cmp_mips.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,21 +1132,12 @@ void CMP_CMIPS::FreeMipSet(CMP_MipSet* pMipSet)
11321132

11331133
for (int i = 0; i < nTotalOldMipLevels; i++)
11341134
{
1135-
// Clean up m_pvec8Data if it was allocated
1136-
if (pMipSet->m_pMipLevelTable[i]->m_pvec8Data)
1137-
{
1138-
delete pMipSet->m_pMipLevelTable[i]->m_pvec8Data;
1139-
pMipSet->m_pMipLevelTable[i]->m_pvec8Data = NULL;
1140-
}
1141-
1142-
if (pMipSet->m_pMipLevelTable[i]->m_pbData)
1143-
{
1144-
free(pMipSet->m_pMipLevelTable[i]->m_pbData);
1145-
pMipSet->m_pMipLevelTable[i]->m_pbData = NULL;
1146-
}
1147-
11481135
if (pMipSet->m_pMipLevelTable[i])
11491136
{
1137+
// Use the dedicated function to clean up MipLevel data
1138+
FreeMipLevelData(pMipSet->m_pMipLevelTable[i]);
1139+
1140+
// Free the MipLevel structure itself
11501141
free(pMipSet->m_pMipLevelTable[i]);
11511142
pMipSet->m_pMipLevelTable[i] = NULL;
11521143
}
@@ -1162,6 +1153,13 @@ void CMP_CMIPS::FreeMipSet(CMP_MipSet* pMipSet)
11621153

11631154
void CMP_CMIPS::FreeMipLevelData(CMP_MipLevel* pMipLevel)
11641155
{
1156+
// Clean up m_pvec8Data if it was allocated
1157+
if (pMipLevel->m_pvec8Data)
1158+
{
1159+
delete pMipLevel->m_pvec8Data;
1160+
pMipLevel->m_pvec8Data = NULL;
1161+
}
1162+
11651163
if (pMipLevel->m_pbData)
11661164
{
11671165
free(pMipLevel->m_pbData);

0 commit comments

Comments
 (0)