[libvirt PATCH 1/3] xenParseHypervisorFeatures: Fix memory leak
Jim Fehlig
jfehlig at suse.com
Fri Apr 16 22:31:56 UTC 2021
On 4/16/21 2:25 AM, Peter Krempa wrote:
> On Thu, Apr 15, 2021 at 17:08:26 +0200, Tim Wiederhake wrote:
>
> Fixes: b523e22521a
>
>> Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>> ---
>> 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.
Since there are only two uses, I prefer this approach as well. E.g.
g_autofree char *tscmode = NULL;
g_autofree char *passthrough = NULL;
Regards,
Jim
More information about the libvir-list
mailing list