[libvirt] [PATCH 06/19] qemu_agent: Resolve Coverity RESOURCE_LEAK
Wang Rui
moon.wangrui at huawei.com
Thu Aug 28 10:25:53 UTC 2014
On 2014/8/28 17:03, Ján Tomko wrote:
> On 08/28/2014 04:40 AM, Wang Rui wrote:
>> On 2014/8/28 4:54, John Ferlan wrote:
>>> Coverity found that on error paths, the 'arg' value wasn't be cleaned
>>> up. Followed the example in qemuAgentSetVCPUs() where upon successful call
>>> to qemuAgentCommand() the 'cpus' is set to NULL; otherwise, when cleanup
>>> occurs the free the memory for 'arg'
>>>
>>> Signed-off-by: John Ferlan <jferlan at redhat.com>
>>> ---
>>> src/qemu/qemu_agent.c | 6 ++++--
>>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>>
[...]
>> Setting arg to NULL can also lead to memory leak.
>> It makes virJSONValueFree(arg) below invalid.
>
> If qemuAgentMakeCommand succeeds, the 'arg' array is now owned by 'cmd' and we
> need to set it to NULL here to prevent double free.
Oh, I got it. Thanks.
More information about the libvir-list
mailing list