On 3/22/19 4:42 AM, Michal Privoznik wrote:
> This functions tries to add a domain moment (love the name!) onto
> a list of domain moments. Firstly, it checks if another moment
> with the same name already exists. Then, it creates an empty
> moment (without initializing its definition) and tries to add the
> moment onto the list dereferencing moment definition in that
> process. If it succeeds (which it never can), only after that it
> sets moment->def.
> 
> Signed-off-by: Michal Privoznik <mpriv...@redhat.com>
> ---
>  src/conf/virdomainmomentobjlist.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <ebl...@redhat.com>

Fixes: 0baf6945ed "snapshot: Minor cleanup to
virDomainSnapshotAssignDef", which I wrote in response to John's good
suggestion, but where I did not pay attention to the fact that the 4
lines in between the one line that I moved dereferenced the same
variable. 'make check' did not catch it; so as penance, I'll be adding
something to the testsuite today using the test driver that would have
caught it.

> 
> diff --git a/src/conf/virdomainmomentobjlist.c 
> b/src/conf/virdomainmomentobjlist.c
> index b2122e7292..01e50ae1d4 100644
> --- a/src/conf/virdomainmomentobjlist.c
> +++ b/src/conf/virdomainmomentobjlist.c
> @@ -227,7 +227,7 @@ virDomainMomentAssignDef(virDomainMomentObjListPtr 
> moments,
>      if (!(moment = virDomainMomentObjNew()))
>          return NULL;
>  
> -    if (virHashAddEntry(moments->objs, moment->def->name, moment) < 0) {
> +    if (virHashAddEntry(moments->objs, def->name, moment) < 0) {
>          VIR_FREE(moment);
>          return NULL;
>      }
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to