- attempt to fix double free bug reported by tomreyn

This commit is contained in:
Mark Vejvoda 2013-03-08 05:24:37 +00:00
parent 198fa1d05d
commit 704935c534
3 changed files with 12 additions and 6 deletions

View File

@ -78,8 +78,7 @@ ClientInterface::ClientInterface() : GameNetworkInterface() {
} }
void ClientInterface::shutdownNetworkCommandListThread() { void ClientInterface::shutdownNetworkCommandListThread() {
//MutexSafeWrapper safeMutex(masterServerThreadAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutex(networkCommandListThreadAccessor,CODE_AT_LINE);
if(networkCommandListThread != NULL) { if(networkCommandListThread != NULL) {
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
this->quit = true; this->quit = true;
@ -94,6 +93,10 @@ void ClientInterface::shutdownNetworkCommandListThread() {
networkCommandListThread = NULL; networkCommandListThread = NULL;
} }
} }
Mutex *tempMutexPtr = networkCommandListThreadAccessor;
networkCommandListThreadAccessor = NULL;
safeMutex.ReleaseLock(false,true);
} }
ClientInterface::~ClientInterface() { ClientInterface::~ClientInterface() {
@ -122,9 +125,6 @@ ClientInterface::~ClientInterface() {
delete clientSocket; delete clientSocket;
clientSocket = NULL; clientSocket = NULL;
delete networkCommandListThreadAccessor;
networkCommandListThreadAccessor = NULL;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }

View File

@ -281,6 +281,7 @@ protected:
public: public:
GameNetworkInterface(); GameNetworkInterface();
virtual ~GameNetworkInterface(){}
//message processimg //message processimg
virtual void update()= 0; virtual void update()= 0;

View File

@ -162,7 +162,7 @@ public:
#endif #endif
} }
} }
void ReleaseLock(bool keepMutex=false) { void ReleaseLock(bool keepMutex=false,bool deleteMutexOnRelease=false) {
if(this->mutex != NULL) { if(this->mutex != NULL) {
#ifdef DEBUG_MUTEXES #ifdef DEBUG_MUTEXES
if(ownerId != "") { if(ownerId != "") {
@ -182,6 +182,11 @@ public:
} }
#endif #endif
if(deleteMutexOnRelease == true) {
delete this->mutex;
this->mutex = NULL;
}
if(keepMutex == false) { if(keepMutex == false) {
this->mutex = NULL; this->mutex = NULL;
} }