Re: [libvirt PATCH 1/3] xenParseHypervisorFeatures: Fix memory leak

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

 



On Thu, Apr 15, 2021 at 17:08:26 +0200, Tim Wiederhake wrote:

Fixes: b523e22521a

> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  src/libxl/xen_common.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c
> index 12a44280cb..ad5a3de116 100644
> --- a/src/libxl/xen_common.c
> +++ b/src/libxl/xen_common.c
> @@ -567,6 +567,7 @@ xenParseHypervisorFeatures(virConf *conf, virDomainDef *def)
>              timer->mode = VIR_DOMAIN_TIMER_MODE_PARAVIRT;
>  
>          def->clock.timers[def->clock.ntimers - 1] = timer;
> +        VIR_FREE(strval);

While this fixes the specific problem, it still leaves possibility for
making a mistake again since 'strval' isn't explicitly freed after the
second use.

A preferrable fix is to use one variable per use when used with
g_autofree or remove g_autofree and explicitly free it after both uses.

CCing Jim to state his preferred solution.

>      }
>  
>      if (xenConfigGetString(conf, "passthrough", &strval, NULL) < 0)
> -- 
> 2.26.2
> 




[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