[libvirt PATCH v2 2/5] virDomainFeaturesDefParse: Fix memory leak

Tim Wiederhake posted 5 patches 4 years, 9 months ago
[libvirt PATCH v2 2/5] virDomainFeaturesDefParse: Fix memory leak
Posted by Tim Wiederhake 4 years, 9 months ago
Fixes: 94013ee04e3945307a71f5c4897d78729e7eaff4
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
---
 src/conf/domain_conf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 17bbeddec6..356398294e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19007,12 +19007,12 @@ virDomainFeaturesDefParse(virDomainDef *def,
         int feature;
         int value;
         g_autofree char *ptval = NULL;
-        g_autofree char *tmp = NULL;
 
         if ((n = virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0)
             return -1;
 
         for (i = 0; i < n; i++) {
+            g_autofree char *tmp = NULL;
             feature = virDomainXenTypeFromString((const char *)nodes[i]->name);
             if (feature < 0) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-- 
2.26.3

Re: [libvirt PATCH v2 2/5] virDomainFeaturesDefParse: Fix memory leak
Posted by Laine Stump 4 years, 9 months ago
On 4/19/21 7:54 AM, Tim Wiederhake wrote:
> Fixes: 94013ee04e3945307a71f5c4897d78729e7eaff4

While not necessary, a short explanation would have led to less time 
spent loooking into the original patch.

> Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
> ---
>   src/conf/domain_conf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 17bbeddec6..356398294e 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -19007,12 +19007,12 @@ virDomainFeaturesDefParse(virDomainDef *def,
>           int feature;
>           int value;
>           g_autofree char *ptval = NULL;
> -        g_autofree char *tmp = NULL;
>   
>           if ((n = virXPathNodeSet("./features/xen/*", ctxt, &nodes)) < 0)
>               return -1;
>   
>           for (i = 0; i < n; i++) {
> +            g_autofree char *tmp = NULL;
>               feature = virDomainXenTypeFromString((const char *)nodes[i]->name);
>               if (feature < 0) {
>                   virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>