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);