From 653f2dc647e1a80a257978d7a8f15f20d242aae4 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Tue, 26 Apr 2016 15:05:09 +0200 Subject: [PATCH] dbuspolicy: fix initialization Change-Id: Ib904512ef25e3da70f784dcd3662f0afd272e3c8 --- src/libdbuspolicy1.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libdbuspolicy1.c b/src/libdbuspolicy1.c index d8163b7..119e460 100644 --- a/src/libdbuspolicy1.c +++ b/src/libdbuspolicy1.c @@ -280,8 +280,7 @@ DBUSPOLICY1_EXPORT void* dbuspolicy1_init(unsigned int bus_type) struct udesc* p_udesc = NULL; kc = (struct kconn*) calloc(1, sizeof(struct kconn)); - p_udesc = (struct udesc*)malloc(sizeof(struct udesc)); - if (!kc || !p_udesc) + if (!kc) goto err; if ((kc->fd = kdbus_open_system_bus()) < 0) @@ -294,16 +293,20 @@ DBUSPOLICY1_EXPORT void* dbuspolicy1_init(unsigned int bus_type) && __internal_init(bus_type, (bus_type == SYSTEM_BUS) ? SYSTEM_BUS_CONF_FILE_SECONDARY : SESSION_BUS_CONF_FILE_SECONDARY) < 0) goto err; + p_udesc = (struct udesc*)malloc(sizeof(struct udesc)); + if (!p_udesc) + goto err; + if (dbuspolicy_init_udesc(kc, bus_type, p_udesc) < 0) goto err; return p_udesc; err: - dbuspolicy1_free(p_udesc); if (kc && kc->fd != -1) close(kc->fd); free(kc); + free(p_udesc); return NULL; } -- 2.7.4