xserver: Branch 'xorg-server-1.4-apple'

George Peter Staplin gstaplin at kemper.freedesktop.org
Tue Sep 23 13:03:22 PDT 2008


 hw/xquartz/pbproxy/x-selection.m |   30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

New commits:
commit aa98db576bc02f0765cb35d0282a894ba3778213
Author: George Peter Staplin <gps at Georges-Workstation.local>
Date:   Tue Sep 23 13:59:25 2008 -0600

    XQuartz: pbproxy: Fix 3 paths that could leak memory.
    
    2 of the paths leaked, when INCR transfers were done.  Now we
    are leak free according to the leaks program for all transfers
    I have tried so far.

diff --git a/hw/xquartz/pbproxy/x-selection.m b/hw/xquartz/pbproxy/x-selection.m
index 7e4bd7c..9556032 100644
--- a/hw/xquartz/pbproxy/x-selection.m
+++ b/hw/xquartz/pbproxy/x-selection.m
@@ -110,9 +110,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if(None == property)
 	return True;
     
-    do {
-	unsigned long newbuflen;
-	unsigned char *newbuf;
+    do 
+    {
+	unsigned long newbuflen = 0;
+	unsigned char *newbuf = NULL;
 	
 #ifdef TEST   
 	printf("bytesleft %lu\n", bytesleft);
@@ -122,8 +123,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 					   offset, length, delete, 
 					   AnyPropertyType,
 					   type, &format, &numitems, 
-					   &bytesleft, &chunk)) {
+					   &bytesleft, &chunk)) 
+	{
 	    DB ("Error while getting window property.\n");
+	    *pdata = null_propdata;
 	    free (buf);
 	    return True;
 	}
@@ -141,10 +144,11 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 #ifdef TEST
 	printf("chunkbytesize %zu\n", chunkbytesize);
 #endif
-	
 	newbuflen = buflen + chunkbytesize;
 	newbuf = realloc (buf, newbuflen);
-	if (NULL == newbuf) {
+
+	if (NULL == newbuf)
+	{
 	    XFree (chunk);
 	    free (buf);
 	    return True;
@@ -837,7 +841,10 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     }
     else if (e->target == atoms->multiple)
     {
-	/* This isn't finished, and may never be, unless I can find a good app. */
+	/*
+	 * This isn't finished, and may never be, unless I can find 
+	 * a good test app.
+	 */
 	[self send_multiple:e];
     } 
     else if (e->target == atoms->utf8_string)
@@ -954,14 +961,16 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
 	{
 	    /* We completed the transfer. */
 	    [self handle_selection:pending.selection type:type propdata:&pending.propdata];
+	    free_propdata(&pdata);
 	    pending.propdata = null_propdata;
 	    pending.requestor = None;
 	    pending.selection = None;
-	} 
+	}
 	else 
 	{
 	    [self append_to_pending:&pdata requestor:e->window];
-	}       
+	    free_propdata (&pdata);
+	}
     }
 }
 
@@ -1084,7 +1093,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     [pb declareTypes:pbtypes owner:nil];
     
     if (YES != [pb setString:string forType:NSStringPboardType]) {
-	DB ("_pasteboard setString:forType: failed!\n");
+	DB ("pasteboard setString:forType: failed!\n");
     }
     [string autorelease];
     DB ("done handling utf8 string\n");
@@ -1126,6 +1135,7 @@ get_property(Window win, Atom property, struct propdata *pdata, Bool delete, Ato
     if (nil == pb) 
     {
 	[self copy_completed:selection];
+	free_propdata (pdata);
 	return;
     }
  


More information about the xorg-commit mailing list