[Xcb] [PATCH] Fix memory leak in _XReply
Aaron Plattner
aplattner at nvidia.com
Wed Sep 17 00:32:22 PDT 2008
_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
-------------- next part --------------
From 118e060126684cb238aa7fff6bf98705de01a709 Mon Sep 17 00:00:00 2001
From: Aaron Plattner <aplattner at nvidia.com>
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/xcb/attachments/20080917/f19d0175/attachment.pgp
More information about the Xcb
mailing list