From fba4818ae850fb8b8b493a12fbb052f5f847489e Mon Sep 17 00:00:00 2001 From: George Fleury Date: Sun, 16 Oct 2011 22:02:11 -0500 Subject: [PATCH] Fix memory leak I was debbuging some code tonight and i found a pointer that is not been freed, so i think there is maybe a memory leak, so it is... there is the malloc caller reverse order: ( malloc cl->statEncList ) <- rfbStatLookupEncoding <- rfbStatRecordEncodingSent <- rfbSendCursorPos <- rfbSendFramebufferUpdate <- rfbProcessEvents I didnt look the whole libvncserver api, but i am using rfbReverseConnection with rfbProcessEvents, and then when the client connection dies, i am calling a rfbShutdownServer and rfbScreenCleanup, but the malloc at rfbStatLookupEncoding isnt been freed. So to free the stats i added a rfbResetStats(cl) after rfbPrintStats(cl) at rfbClientConnectionGone in rfbserver.c before free the cl pointer. (at rfbserver.c line 555). And this, obviously, is correcting the memory leak. Signed-off-by: Johannes Schindelin --- libvncserver/rfbserver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c index 63f21db..cb37da3 100644 --- a/libvncserver/rfbserver.c +++ b/libvncserver/rfbserver.c @@ -569,6 +569,7 @@ rfbClientConnectionGone(rfbClientPtr cl) TINI_MUTEX(cl->sendMutex); rfbPrintStats(cl); + rfbResetStats(cl); free(cl); }