I think this belong here rather than on [EMAIL PROTECTED]

----- Forwarded message from Aaron Plattner <[EMAIL PROTECTED]> -----

> From: Aaron Plattner <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [Xcb] [PATCH] Fix memory leak in _XReply
> Date: Wed, 17 Sep 2008 00:27:21 -0700
> X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW
>       autolearn=ham version=3.2.4
> User-Agent: Mutt/1.5.16 (2007-06-09)
> 
> _XReply fails to free errors that it gets back from xcb_wait_for_reply and
> process_responses, causing memory leaks in, e.g., compiz when it gets back
> the inevitable BadWindow responses inherent to the Composite extension.
> 
> -- Aaron

----- End forwarded message -----

-- 
Julien Danjou
// ᐰ <[EMAIL PROTECTED]>   http://julien.danjou.info
// 9A0D 5FD9 EB42 22F6 8974  C95C A462 B51E C2FE E5CD
From 118e060126684cb238aa7fff6bf98705de01a709 Mon Sep 17 00:00:00 2001
From: Aaron Plattner <[EMAIL PROTECTED]>
Date: Wed, 17 Sep 2008 00:08:52 -0700
Subject: [PATCH] Fix a memory leak in _XReply.

When process_responses encounters an error and current_error is non-NULL, it
just stashes the event pointer into that and returns, leaving it up to the
caller to free the resulting error.  _XReply failed to free these errors.
---
 src/xcb_io.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/xcb_io.c b/src/xcb_io.c
index 05f3959..67df3f3 100644
--- a/src/xcb_io.c
+++ b/src/xcb_io.c
@@ -409,15 +409,20 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
 				{
 					case X_LookupColor:
 					case X_AllocNamedColor:
+						free(err);
 						return 0;
 				}
 				break;
 			case BadFont:
 				if(err->majorCode == X_QueryFont)
+				{
+					free(err);
 					return 0;
+				}
 				break;
 			case BadAlloc:
 			case BadAccess:
+				free(err);
 				return 0;
 		}
 
@@ -426,10 +431,16 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
 		 * want to suppress the error.
 		 */
 		for(ext = dpy->ext_procs; ext; ext = ext->next)
+		{
 			if(ext->error && ext->error(dpy, err, &ext->codes, &ret_code))
+			{
+				free(err);
 				return ret_code;
+			}
+		}
 
-		_XError(dpy, (xError *) error);
+		_XError(dpy, err);
+		free(err);
 		return 0;
 	}
 
-- 
1.5.6.4

_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to