fix memory leaks detected using valgrind

pull/1/head
dscho 20 years ago
parent 3a7e70de49
commit 446a6fabac

@ -1,6 +1,9 @@
2005-05-14 Karl Runge <runge@karlrunge.com> 2005-05-14 Karl Runge <runge@karlrunge.com>
* x11vnc: more work on -scrollcopyrect and -xkb modes. * x11vnc: more work on -scrollcopyrect and -xkb modes.
2005-05-13 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* libvncserver/{main,rfbserver,sockets}.c: fix memory leaks (valgrind)
2005-05-07 Johannes E. Schindelin <Johannes.Schindelin@gmx.de> 2005-05-07 Johannes E. Schindelin <Johannes.Schindelin@gmx.de>
* libvncserver/rfbserver.c: fix memory leak pointed out by Tim Jansen * libvncserver/rfbserver.c: fix memory leak pointed out by Tim Jansen
* libvncserver/{httpd,main,rfbserver,sockets}.c, rfb/rfb.h: * libvncserver/{httpd,main,rfbserver,sockets}.c, rfb/rfb.h:

@ -258,6 +258,7 @@ void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
c->xhot = 16; c->yhot = 24; c->xhot = 16; c->yhot = 24;
c->richSource = (char*)malloc(w*h*bpp); c->richSource = (char*)malloc(w*h*bpp);
c->cleanupRichSource = TRUE;
for(j=0;j<h;j++) { for(j=0;j<h;j++) {
for(i=0;i<w;i++) { for(i=0;i<w;i++) {
c->richSource[j*w*bpp+i*bpp+0]=i*0xff/w; c->richSource[j*w*bpp+i*bpp+0]=i*0xff/w;

@ -532,7 +532,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
int width,int height,int bitsPerSample,int samplesPerPixel, int width,int height,int bitsPerSample,int samplesPerPixel,
int bytesPerPixel) int bytesPerPixel)
{ {
rfbScreenInfoPtr screen=malloc(sizeof(rfbScreenInfo)); rfbScreenInfoPtr screen=calloc(sizeof(rfbScreenInfo),1);
INIT_MUTEX(logMutex); INIT_MUTEX(logMutex);
@ -759,6 +759,7 @@ void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
if (cl->sock > -1) if (cl->sock > -1)
/* we don't care about maxfd here, because the server goes away */ /* we don't care about maxfd here, because the server goes away */
rfbCloseClient(cl); rfbCloseClient(cl);
rfbReleaseClientIterator(iter);
} }
rfbShutdownSockets(screen); rfbShutdownSockets(screen);

@ -413,7 +413,7 @@ rfbClientConnectionGone(cl)
if (cl->next) if (cl->next)
cl->next->prev = cl->prev; cl->next->prev = cl->prev;
if(cl->sock) if(cl->sock>0)
close(cl->sock); close(cl->sock);
#ifdef LIBVNCSERVER_HAVE_LIBZ #ifdef LIBVNCSERVER_HAVE_LIBZ
@ -610,6 +610,8 @@ rfbProcessClientInitMessage(cl)
return; return;
} }
memset(buf,0,256);
si->framebufferWidth = Swap16IfLE(cl->screen->width); si->framebufferWidth = Swap16IfLE(cl->screen->width);
si->framebufferHeight = Swap16IfLE(cl->screen->height); si->framebufferHeight = Swap16IfLE(cl->screen->height);
si->format = cl->screen->serverFormat; si->format = cl->screen->serverFormat;
@ -617,10 +619,7 @@ rfbProcessClientInitMessage(cl)
si->format.greenMax = Swap16IfLE(si->format.greenMax); si->format.greenMax = Swap16IfLE(si->format.greenMax);
si->format.blueMax = Swap16IfLE(si->format.blueMax); si->format.blueMax = Swap16IfLE(si->format.blueMax);
if (strlen(cl->screen->desktopName) > 128) /* sanity check on desktop name len */ strncpy(buf + sz_rfbServerInitMsg, cl->screen->desktopName, 127);
((char*)cl->screen->desktopName)[128] = 0;
strcpy(buf + sz_rfbServerInitMsg, cl->screen->desktopName);
len = strlen(buf + sz_rfbServerInitMsg); len = strlen(buf + sz_rfbServerInitMsg);
si->nameLength = Swap32IfLE(len); si->nameLength = Swap32IfLE(len);

Loading…
Cancel
Save