From: John Ferlan Date: Fri, 2 Jun 2017 11:56:59 +0000 (-0400) Subject: interface: Consume @def in virInterfaceObjNew X-Git-Tag: v3.5.0-rc1~158 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92840eb3a7e47cdf761e52afccc41d2a35327fbd;p=thirdparty%2Flibvirt.git interface: Consume @def in virInterfaceObjNew Move the consumption of @def in virInterfaceObjNew and then handle that in the error path of virInterfaceObjListAssignDef since it's caller expects to need to free @def when NULL is returned and so would virInterfaceObjFree. Signed-off-by: John Ferlan --- diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 1e3f25c047..159fcb292c 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -47,7 +47,7 @@ struct _virInterfaceObjList { /* virInterfaceObj manipulation */ static virInterfaceObjPtr -virInterfaceObjNew(void) +virInterfaceObjNew(virInterfaceDefPtr def) { virInterfaceObjPtr obj; @@ -62,6 +62,7 @@ virInterfaceObjNew(void) } virInterfaceObjLock(obj); + obj->def = def; return obj; } @@ -251,17 +252,17 @@ virInterfaceObjListAssignDef(virInterfaceObjListPtr interfaces, return obj; } - if (!(obj = virInterfaceObjNew())) + if (!(obj = virInterfaceObjNew(def))) return NULL; if (VIR_APPEND_ELEMENT_COPY(interfaces->objs, interfaces->count, obj) < 0) { + obj->def = NULL; virInterfaceObjUnlock(obj); virInterfaceObjFree(obj); return NULL; } - obj->def = def; return obj; }