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: xiajidong
Subject: Re: [PATCH] hw/audio: fix a memory leak in OPLCreate()
Date: Thu, 24 Oct 2019 05:36:06 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0



On 10/24/19 4:25 AM, Stefano Garzarella wrote:
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?
ok, I understand it.

Thanks,
Stefano


Thanks,
Jidong Xia





reply via email to

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