qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()


From: Stefano Garzarella
Subject: Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
Date: Thu, 24 Oct 2019 10:25:00 +0200
User-agent: NeoMutt/20180716

On Wed, Oct 23, 2019 at 05:53:40PM +0800, Jidong Xia wrote:
> There is a memory leak in OPLCreate(),Should free allocated mem
> before return.
> 
> Signed-off-by: Jidong Xia <address@hidden>
> ---
>  hw/audio/fmopl.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c
> index 9f50a89..ca9825b 100644
> --- a/hw/audio/fmopl.c
> +++ b/hw/audio/fmopl.c
> @@ -1112,6 +1112,7 @@ FM_OPL *OPLCreate(int clock, int rate)
>               opl_dbg_maxchip++;
>       }
>  #endif
> +     free(ptr);
>       return OPL;

I don't know this code well, but I don't think is correct to free 'ptr' in
the success case, since it is the pointer returned by this function that
will be freed by OPLDestroy().

Does that sound right or did I miss something?

Thanks,
Stefano



reply via email to

[Prev in Thread] Current Thread [Next in Thread]