[libvirt] [PATCH] virDomainMomentAssignDef: Don't dereference a NULL pointer
Eric Blake
eblake at redhat.com
Fri Mar 22 11:44:45 UTC 2019
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 at redhat.com>
> ---
> src/conf/virdomainmomentobjlist.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <eblake at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190322/cbc5db1b/attachment-0001.sig>
More information about the libvir-list
mailing list