--- ./main.c.thread2 2007-05-17 15:12:57.000000000 +0100 +++ ./main.c 2007-05-17 15:13:51.000000000 +0100 @@ -441,11 +441,14 @@ rfbBool haveUpdate; sraRegion* updateRegion; + rfbIncrClientRef(cl); + while (1) { haveUpdate = false; while (!haveUpdate) { if (cl->sock == -1) { /* Client has disconnected. */ + rfbDecrClientRef(cl); return NULL; } LOCK(cl->updateMutex); @@ -473,13 +476,13 @@ UNLOCK(cl->updateMutex); /* Now actually send the update. */ - rfbIncrClientRef(cl); rfbSendFramebufferUpdate(cl, updateRegion); - rfbDecrClientRef(cl); sraRgnDestroy(updateRegion); } + rfbDecrClientRef(cl); + /* Not reached. */ return NULL; }