[libvirt] [PATCH] conf: Fix memory leaks in virStoragePoolDefParseSource

Osier Yang jyang at redhat.com
Wed May 9 08:01:28 UTC 2012


On 2012年05月09日 14:15, Alex Jia wrote:
> Detected by valgrind. Leaks are introduced in commit 122fa379.
>
> src/conf/storage_conf.c: fix memory leaks.
>
> How to reproduce?
> $ make&&  make -C tests check TESTS=storagepoolxml2xmltest
> $ cd tests&&  valgrind -v --leak-check=full ./storagepoolxml2xmltest
>
> actual result:
> ==28571== LEAK SUMMARY:
> ==28571==    definitely lost: 40 bytes in 5 blocks
> ==28571==    indirectly lost: 0 bytes in 0 blocks
> ==28571==      possibly lost: 0 bytes in 0 blocks
> ==28571==    still reachable: 1,054 bytes in 21 blocks
> ==28571==         suppressed: 0 bytes in 0 blocks
>
> Signed-off-by: Alex Jia<ajia at redhat.com>
> ---
>   src/conf/storage_conf.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index 0b34f28..668e679 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -462,6 +462,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
>                       goto cleanup;
>                   }
>               }
> +            VIR_FREE(nodeset);
>           }
>       }
>

NACK, not the right fix, "nodeset" will still be used by the 'for' loop.

Osier




More information about the libvir-list mailing list