[libvirt] [PATCH 02/17] Avoid leak if virDomainSoundCodecDefParseXML return error

Doug Goldstein cardoe at gentoo.org
Tue Sep 24 19:53:20 UTC 2013


On Tue, Sep 24, 2013 at 11:03 AM, Daniel P. Berrange
<berrange at redhat.com> wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> If virDomainSoundCodecDefParseXML returns an error (eg due
> to OOM), then the xml nodeset codecNodes is leaked.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>  src/conf/domain_conf.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 81314bc..ccb61aa 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -8470,8 +8470,10 @@ virDomainSoundDefParseXML(const xmlNodePtr node,
>
>              for (i = 0; i < ncodecs; i++) {
>                  virDomainSoundCodecDefPtr codec = virDomainSoundCodecDefParseXML(codecNodes[i]);
> -                if (codec == NULL)
> +                if (codec == NULL) {
> +                    VIR_FREE(codecNodes);
>                      goto error;
> +                }
>
>                  codec->cad = def->ncodecs; /* that will do for now */
>                  def->codecs[def->ncodecs++] = codec;
> --
> 1.8.3.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

ACK

-- 
Doug Goldstein




More information about the libvir-list mailing list