Fix use-after-free

pull/3/head
Quentin BUATHIER 6 years ago
parent 474f64e5db
commit 96e163bdae

@ -1081,15 +1081,21 @@ void rfbInitServer(rfbScreenInfoPtr screen)
void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) { void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
if(disconnectClients) { if(disconnectClients) {
rfbClientPtr cl;
rfbClientIteratorPtr iter = rfbGetClientIterator(screen); rfbClientIteratorPtr iter = rfbGetClientIterator(screen);
while( (cl = rfbClientIteratorNext(iter)) ) { rfbClientPtr nextCl, currentCl = rfbClientIteratorNext(iter);
if (cl->sock > -1) {
/* we don't care about maxfd here, because the server goes away */ while(currentCl) {
rfbCloseClient(cl); nextCl = rfbClientIteratorNext(iter);
rfbClientConnectionGone(cl); if (currentCl->sock > -1) {
/* we don't care about maxfd here, because the server goes away */
rfbCloseClient(currentCl);
} }
rfbClientConnectionGone(currentCl);
currentCl = nextCl;
} }
rfbReleaseClientIterator(iter); rfbReleaseClientIterator(iter);
} }

Loading…
Cancel
Save