mirror of
https://github.com/electronicarts/CNC_TS_and_RA2_Mission_Editor.git
synced 2025-04-30 09:01:41 -04:00
fixed potential crash when reloading images (safe memory release, avoid double free) .
This commit is contained in:
parent
20adb95961
commit
102f919e96
2 changed files with 15 additions and 9 deletions
|
@ -3888,10 +3888,12 @@ void CLoading::FreeAll()
|
|||
((LPDIRECTDRAWSURFACE4)i->second.pic)->Release();
|
||||
}
|
||||
} else {
|
||||
if (i->second.pic != NULL) {
|
||||
delete[] i->second.pic;
|
||||
if (auto pPic = std::exchange(i->second.pic, nullptr)) {
|
||||
delete[](pPic);
|
||||
}
|
||||
if (auto pBorder = std::exchange(i->second.vborder, nullptr)) {
|
||||
delete[](pBorder);
|
||||
}
|
||||
if (i->second.vborder) delete[] i->second.vborder;
|
||||
}
|
||||
#else
|
||||
if (i->second.pic != NULL) i->second.pic->Release();
|
||||
|
|
|
@ -618,10 +618,12 @@ void CMapData::LoadMap(const std::string& file)
|
|||
((LPDIRECTDRAWSURFACE4)it->second.pic)->Release();
|
||||
}
|
||||
} else {
|
||||
if (it->second.pic != NULL) {
|
||||
delete[] it->second.pic;
|
||||
if (auto pPic = std::exchange(it->second.pic, nullptr)) {
|
||||
delete[](pPic);
|
||||
}
|
||||
if (auto pBorder = std::exchange(it->second.vborder, nullptr)) {
|
||||
delete[](pBorder);
|
||||
}
|
||||
if (it->second.vborder) delete[] it->second.vborder;
|
||||
}
|
||||
#else
|
||||
if (it->second.pic != NULL) it->second.pic->Release();
|
||||
|
@ -3791,10 +3793,12 @@ void CMapData::CreateMap(DWORD dwWidth, DWORD dwHeight, LPCTSTR lpTerrainType, D
|
|||
((LPDIRECTDRAWSURFACE4)it->second.pic)->Release();
|
||||
}
|
||||
} else {
|
||||
if (it->second.pic != NULL) {
|
||||
delete[] it->second.pic;
|
||||
if (auto pPic = std::exchange(it->second.pic, nullptr)) {
|
||||
delete[](pPic);
|
||||
}
|
||||
if (auto pBorder = std::exchange(it->second.vborder, nullptr)) {
|
||||
delete[](pBorder);
|
||||
}
|
||||
if (it->second.vborder) delete[] it->second.vborder;
|
||||
}
|
||||
#else
|
||||
if (it->second.pic != NULL) it->second.pic->Release();
|
||||
|
|
Loading…
Add table
Reference in a new issue