Re: [PATCH] virDomainMomentAssignDef: Don't dereference a NULL pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <mprivozn@xxxxxxxxxx>
> ---
>  src/conf/virdomainmomentobjlist.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@xxxxxxxxxx>

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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux