diff --git a/source/shared_lib/sources/platform/posix/socket.cpp b/source/shared_lib/sources/platform/posix/socket.cpp index cfe21014a..8f6e3c5f5 100644 --- a/source/shared_lib/sources/platform/posix/socket.cpp +++ b/source/shared_lib/sources/platform/posix/socket.cpp @@ -195,8 +195,7 @@ Mutex UPNP_Tools::mutexUPNP; int nErrorID = 0 ) { // Build basic error string - static char acErrorBuffer[256]; - std::ostrstream outs(acErrorBuffer, (sizeof(acErrorBuffer) / sizeof(acErrorBuffer[0]))); + static char acErrorBuffer[8096]; outs << pcMessagePrefix << ": "; // Tack appropriate canned message onto end of supplied message @@ -218,7 +217,7 @@ Mutex UPNP_Tools::mutexUPNP; // Finish error message off and return it. outs << std::ends; - acErrorBuffer[(sizeof(acErrorBuffer) / sizeof(acErrorBuffer[0])) - 1] = '\0'; + acErrorBuffer[8095] = '\0'; return acErrorBuffer; } diff --git a/source/shared_lib/sources/platform/sdl/thread.cpp b/source/shared_lib/sources/platform/sdl/thread.cpp index 289017195..96d90b906 100644 --- a/source/shared_lib/sources/platform/sdl/thread.cpp +++ b/source/shared_lib/sources/platform/sdl/thread.cpp @@ -42,6 +42,11 @@ Thread::~Thread() { MutexSafeWrapper safeMutex(&Thread::mutexthreadList); std::vector::iterator iterFind = std::find(Thread::threadList.begin(),Thread::threadList.end(),this); + if(iterFind == Thread::threadList.end()) { + char szBuf[1024]=""; + snprintf(szBuf,1023,"In [%s::%s Line: %d] iterFind == Thread::threadList.end()",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); + throw megaglest_runtime_error(szBuf); + } Thread::threadList.erase(iterFind); safeMutex.ReleaseLock(); } @@ -428,7 +433,9 @@ void MasterSlaveThreadController::clearSlaves(bool clearListOnly) { if(clearListOnly == false) { for(unsigned int i = 0; i < this->slaveThreadList.size(); ++i) { SlaveThreadControllerInterface *slave = this->slaveThreadList[i]; - slave->setMasterController(NULL); + if(slave != NULL) { + slave->setMasterController(NULL); + } } } this->slaveThreadList.clear(); @@ -457,7 +464,9 @@ void MasterSlaveThreadController::setSlaves(std::vectorslaveThreadList.empty() == false) { for(unsigned int i = 0; i < this->slaveThreadList.size(); ++i) { SlaveThreadControllerInterface *slave = this->slaveThreadList[i]; - slave->setMasterController(this); + if(slave != NULL) { + slave->setMasterController(this); + } } } } @@ -472,7 +481,9 @@ void MasterSlaveThreadController::signalSlaves(void *userdata) { if(this->slaveThreadList.empty() == false) { for(unsigned int i = 0; i < this->slaveThreadList.size(); ++i) { SlaveThreadControllerInterface *slave = this->slaveThreadList[i]; - slave->signalSlave(userdata); + if(slave != NULL) { + slave->signalSlave(userdata); + } } }