summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Vignatti <tiago.vignatti@nokia.com>2011-03-25 18:56:02 +0200
committerTiago Vignatti <tiago.vignatti@nokia.com>2011-04-04 15:41:13 +0300
commit8ab92cd9822510f426d179a636ef34bb0ace3bb3 (patch)
tree1039bf8d86464790251a412038ef99f7ad8f33cb
parentaa7096ca6f108e399d9916639cf20c57f9776305 (diff)
xfree86: dri2: fix memory leak and free resources properly
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com> Reviewed-by: Nicolas Peninguy <nico@lostgeeks.org> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--hw/xfree86/dri2/dri2.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 9ca378fed..10be59953 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -221,11 +221,16 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
if (ref == NULL)
return BadAlloc;
- if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
+ if (!AddResource(dri2_id, dri2DrawableRes, pPriv)) {
+ free(ref);
return BadAlloc;
+ }
if (!DRI2LookupDrawableRef(pPriv, id))
- if (!AddResource(id, dri2DrawableRes, pPriv))
+ if (!AddResource(id, dri2DrawableRes, pPriv)) {
+ FreeResourceByType(dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
return BadAlloc;
+ }
ref->id = id;
ref->dri2_id = dri2_id;