[PATCH 2/2] xfree86: dri2: free variable properly if code fails

Tiago Vignatti tiago.vignatti at nokia.com
Tue Jun 29 09:00:17 PDT 2010


Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
Same as the previous patch: I'm not exactly seeing any problem or segfault
with this code. I just got this issue with the static analyzer.

 hw/xfree86/dri2/dri2.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d4181c9..26f5ac4 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -207,10 +207,10 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
 	return BadAlloc;
 	
     if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
-	return BadAlloc;
+	goto err_out;
     if (!DRI2LookupDrawableRef(pPriv, id))
 	if (!AddResource(id, dri2DrawableRes, pPriv))
-	    return BadAlloc;
+	    goto err_out;
 
     ref->id = id;
     ref->dri2_id = dri2_id; 
@@ -219,6 +219,10 @@ DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
     list_add(&ref->link, &pPriv->reference_list);
 
     return Success;
+
+err_out:
+    free(ref);
+    return BadAlloc;
 }
 
 int
-- 
1.7.1.226.g770c5



More information about the xorg-devel mailing list