]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainMomentAssignDef: Don't dereference a NULL pointer
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Mar 2019 09:39:06 +0000 (10:39 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Mar 2019 10:19:41 +0000 (11:19 +0100)
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@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/conf/virdomainmomentobjlist.c

index b2122e7292afbb79abd257a3627d5bd7970c8ac8..01e50ae1d431bd44f5f67aa6f990ca07e7136ada 100644 (file)
@@ -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;
     }