NetBoard: guard against freeing null pointers and INetBoard needed a virtual destructor (was causing crashes on exit on some systems)

This commit is contained in:
Bart Trzynadlowski 2023-03-14 11:18:20 -07:00
parent 3848d276da
commit b5ca365928
2 changed files with 7 additions and 3 deletions

View file

@ -30,6 +30,10 @@
class INetBoard class INetBoard
{ {
public: public:
virtual ~INetBoard()
{
}
virtual void SaveState(CBlockFile* SaveState) = 0; virtual void SaveState(CBlockFile* SaveState) = 0;
virtual void LoadState(CBlockFile* SaveState) = 0; virtual void LoadState(CBlockFile* SaveState) = 0;

View file

@ -111,11 +111,11 @@
#endif #endif
#ifndef SAFE_DELETE #ifndef SAFE_DELETE
#define SAFE_DELETE(p) delete (p); (p) = NULL; #define SAFE_DELETE(p) if (p != nullptr) { delete (p); (p) = NULL; }
#endif #endif
#ifndef SAFE_ARRAY_DELETE #ifndef SAFE_ARRAY_DELETE
#define SAFE_ARRAY_DELETE(x) delete[] x; x = NULL; #define SAFE_ARRAY_DELETE(x) if (x != nullptr) { delete[] x; x = NULL; }
#endif #endif
static int(*Runnet68kCB)(int cycles); static int(*Runnet68kCB)(int cycles);
@ -667,7 +667,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d)
case 0x80: case 0x80:
nets->Send((const char*)CommRAM + send_offset, send_size); nets->Send((const char*)CommRAM + send_offset, send_size);
DebugLog("send enable off=%x size=%x\n", send_offset, send_size); DebugLog("send enable off=%x size=%x\n", send_offset, send_size);
#ifdef NET_DEBUG #ifdef NET_DEBUG
DebugLog("transmitting : "); DebugLog("transmitting : ");
if (send_size > 50) //too big for print, so... if (send_size > 50) //too big for print, so...