Re: [PATCH] domain_conf: Fix memory leak when free'ing virDomainObj

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

 



On Mon, Aug 09, 2021 at 03:04:35PM +0800, Luke Yue wrote:
> Free dom->deprecations when free'ing virDomainObj
> 
> Signed-off-by: Luke Yue <lukedyue@xxxxxxxxx>
> ---
>  src/conf/domain_conf.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 09da4ab952..2527cd1d70 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -3733,6 +3733,7 @@ void virDomainDefFree(virDomainDef *def)
>  static void virDomainObjDispose(void *obj)
>  {
>      virDomainObj *dom = obj;
> +    size_t i = 0;
>  
>      VIR_DEBUG("obj=%p", dom);
>      virCondDestroy(&dom->cond);
> @@ -3742,6 +3743,11 @@ static void virDomainObjDispose(void *obj)
>      if (dom->privateDataFreeFunc)
>          (dom->privateDataFreeFunc)(dom->privateData);
>  
> +    for (i = 0; i < dom->ndeprecations; i++) {
> +        g_free(dom->deprecations[i]);
> +    }
> +    g_free(dom->deprecations);
> +

Nice catch, can you add the code to separate function? For example:

virDomainObjDepracationFree()

Otherwise looks good.

Pavel

>      virDomainSnapshotObjListFree(dom->snapshots);
>      virDomainCheckpointObjListFree(dom->checkpoints);
>  }
> -- 
> 2.32.0
> 

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux