summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--examples/example.c1
-rw-r--r--libvncserver/main.c3
-rw-r--r--libvncserver/rfbserver.c9
4 files changed, 10 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index dca56ea..c2e7dc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
2005-05-14 Karl Runge <[email protected]>
* x11vnc: more work on -scrollcopyrect and -xkb modes.
+2005-05-13 Johannes E. Schindelin <[email protected]>
+ * libvncserver/{main,rfbserver,sockets}.c: fix memory leaks (valgrind)
+
2005-05-07 Johannes E. Schindelin <[email protected]>
* libvncserver/rfbserver.c: fix memory leak pointed out by Tim Jansen
* libvncserver/{httpd,main,rfbserver,sockets}.c, rfb/rfb.h:
diff --git a/examples/example.c b/examples/example.c
index f4a1f08..59ac518 100644
--- a/examples/example.c
+++ b/examples/example.c
@@ -258,6 +258,7 @@ void MakeRichCursor(rfbScreenInfoPtr rfbScreen)
c->xhot = 16; c->yhot = 24;
c->richSource = (char*)malloc(w*h*bpp);
+ c->cleanupRichSource = TRUE;
for(j=0;j<h;j++) {
for(i=0;i<w;i++) {
c->richSource[j*w*bpp+i*bpp+0]=i*0xff/w;
diff --git a/libvncserver/main.c b/libvncserver/main.c
index d2dc69f..4e59c98 100644
--- a/libvncserver/main.c
+++ b/libvncserver/main.c
@@ -532,7 +532,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
int width,int height,int bitsPerSample,int samplesPerPixel,
int bytesPerPixel)
{
- rfbScreenInfoPtr screen=malloc(sizeof(rfbScreenInfo));
+ rfbScreenInfoPtr screen=calloc(sizeof(rfbScreenInfo),1);
INIT_MUTEX(logMutex);
@@ -759,6 +759,7 @@ void rfbShutdownServer(rfbScreenInfoPtr screen,rfbBool disconnectClients) {
if (cl->sock > -1)
/* we don't care about maxfd here, because the server goes away */
rfbCloseClient(cl);
+ rfbReleaseClientIterator(iter);
}
rfbShutdownSockets(screen);
diff --git a/libvncserver/rfbserver.c b/libvncserver/rfbserver.c
index 74f4fbd..7790522 100644
--- a/libvncserver/rfbserver.c
+++ b/libvncserver/rfbserver.c
@@ -413,7 +413,7 @@ rfbClientConnectionGone(cl)
if (cl->next)
cl->next->prev = cl->prev;
- if(cl->sock)
+ if(cl->sock>0)
close(cl->sock);
#ifdef LIBVNCSERVER_HAVE_LIBZ
@@ -610,6 +610,8 @@ rfbProcessClientInitMessage(cl)
return;
}
+ memset(buf,0,256);
+
si->framebufferWidth = Swap16IfLE(cl->screen->width);
si->framebufferHeight = Swap16IfLE(cl->screen->height);
si->format = cl->screen->serverFormat;
@@ -617,10 +619,7 @@ rfbProcessClientInitMessage(cl)
si->format.greenMax = Swap16IfLE(si->format.greenMax);
si->format.blueMax = Swap16IfLE(si->format.blueMax);
- if (strlen(cl->screen->desktopName) > 128) /* sanity check on desktop name len */
- ((char*)cl->screen->desktopName)[128] = 0;
-
- strcpy(buf + sz_rfbServerInitMsg, cl->screen->desktopName);
+ strncpy(buf + sz_rfbServerInitMsg, cl->screen->desktopName, 127);
len = strlen(buf + sz_rfbServerInitMsg);
si->nameLength = Swap32IfLE(len);