- IEC 61850 server: fixed potential null pointer dereference in multi

thread mode when server is stopped
pull/228/head
Michael Zillgith 5 years ago
parent 6a2db3fe46
commit 95f751ef63

@ -541,6 +541,8 @@ isoServerThread(void* isoServerParam)
if (DEBUG_ISO_SERVER) if (DEBUG_ISO_SERVER)
printf("ISO_SERVER: starting server failed!\n"); printf("ISO_SERVER: starting server failed!\n");
self->serverSocket = NULL;
goto cleanUp; goto cleanUp;
} }
@ -557,7 +559,6 @@ isoServerThread(void* isoServerParam)
self->state = ISO_SVR_STATE_STOPPED; self->state = ISO_SVR_STATE_STOPPED;
cleanUp: cleanUp:
self->serverSocket = NULL;
if (DEBUG_ISO_SERVER) if (DEBUG_ISO_SERVER)
printf("ISO_SERVER: isoServerThread %p stopped\n", &isoServerParam); printf("ISO_SERVER: isoServerThread %p stopped\n", &isoServerParam);
@ -758,11 +759,16 @@ IsoServer_stopListeningThreadless(IsoServer self)
void void
IsoServer_stopListening(IsoServer self) IsoServer_stopListening(IsoServer self)
{ {
stopListening(self); setState(self, ISO_SVR_STATE_STOPPED);
if (self->serverThread != NULL) if (self->serverThread != NULL)
Thread_destroy(self->serverThread); Thread_destroy(self->serverThread);
if (self->serverSocket != NULL) {
ServerSocket_destroy((ServerSocket) self->serverSocket);
self->serverSocket = NULL;
}
closeAllOpenClientConnections(self); closeAllOpenClientConnections(self);
/* Wait for connection threads to finish */ /* Wait for connection threads to finish */

Loading…
Cancel
Save