[PATCH 2/2] xfree86: dri2: free variable properly if code fails
Michel Dänzer
michel at daenzer.net
Tue Jun 29 09:55:02 PDT 2010
On Die, 2010-06-29 at 19:00 +0300, Tiago Vignatti wrote:
> 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;
The second error path should also free the first resource created,
shouldn't it?
--
Earthling Michel Dänzer | http://www.vmware.com
Libre software enthusiast | Debian, X and DRI developer
More information about the xorg-devel
mailing list