@@ -1134,9 +1134,7 @@ void CMP_CMIPS::FreeMipSet(CMP_MipSet* pMipSet)
11341134 {
11351135 if (pMipSet->m_pMipLevelTable [i])
11361136 {
1137- // Use the dedicated function to clean up MipLevel data
1138- FreeMipLevelData (pMipSet->m_pMipLevelTable [i]);
1139-
1137+ FreeMipLevelData (pMipSet->m_pMipLevelTable [i], pMipSet->m_format );
11401138 // Free the MipLevel structure itself
11411139 free (pMipSet->m_pMipLevelTable [i]);
11421140 pMipSet->m_pMipLevelTable [i] = NULL ;
@@ -1151,15 +1149,22 @@ void CMP_CMIPS::FreeMipSet(CMP_MipSet* pMipSet)
11511149 }
11521150}
11531151
1154- void CMP_CMIPS::FreeMipLevelData (CMP_MipLevel* pMipLevel)
1152+ void CMP_CMIPS::FreeMipLevelData (CMP_MipLevel* pMipLevel, CMP_FORMAT setFormat )
11551153{
1156- // Clean up m_pvec8Data if it was allocated
1157- if (pMipLevel->m_pvec8Data )
1154+ if (!pMipLevel)
1155+ return ;
1156+
1157+ // When Basis is used, m_pvec8data is assigned to a CMP_VEC8, this uses new()
1158+ // so we have to use delete.
1159+ // TODO: I don't know the status of BASIS, but we certainly don't use it at YDMS. - ProbablePrime
1160+ if (setFormat == CMP_FORMAT_BASIS )
11581161 {
11591162 delete pMipLevel->m_pvec8Data ;
11601163 pMipLevel->m_pvec8Data = NULL ;
1164+ return ;
11611165 }
11621166
1167+ // Other formats, all use variations of malloc which means they are safe to use with free.
11631168 if (pMipLevel->m_pbData )
11641169 {
11651170 free (pMipLevel->m_pbData );
0 commit comments