From: Daniel Wagner <daniel.wag...@bmw-carit.de>

---
 plugins/session_policy_ivi.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c
index 25be047..c4e0e42 100644
--- a/plugins/session_policy_ivi.c
+++ b/plugins/session_policy_ivi.c
@@ -118,12 +118,18 @@ static void selinux_context_reply(unsigned char *context, 
unsigned int size,
                                        void *user_data)
 {
        struct create_data *data = user_data;
-       struct policy_data *policy;
+       struct policy_data *policy = NULL;
        char *ident;
 
        DBG("session %p", data->session);
 
        ident = parse_ident(context, size);
+       if (ident == NULL)
+               goto err;
+
+       policy = g_hash_table_lookup(ident_hash, ident);
+       if (policy != NULL)
+               goto out;
 
        policy = g_try_new0(struct policy_data, 1);
        if (policy == NULL)
@@ -133,6 +139,9 @@ static void selinux_context_reply(unsigned char *context, 
unsigned int size,
        if (policy->config == NULL)
                goto err;
 
+out:
+       policy->session = data->session;
+
        g_hash_table_replace(session_hash, data->session, policy);
 
        (*data->callback)(data->session, policy->config, data->user_data);
@@ -144,7 +153,8 @@ static void selinux_context_reply(unsigned char *context, 
unsigned int size,
 err:
        (*data->callback)(data->session, NULL, data->user_data);
 
-       cleanup_policy(policy);
+       if (policy != NULL && policy->ident == NULL)
+               cleanup_policy(policy);
 
        g_free(data);
        g_free(ident);
@@ -189,8 +199,10 @@ static void policy_ivi_destroy(struct connman_session 
*session)
        policy = g_hash_table_lookup(session_hash, session);
 
        g_hash_table_remove(session_hash, session);
+       policy->session = NULL;
 
-       cleanup_policy(policy);
+       if (policy->ident == NULL)
+               cleanup_policy(policy);
 }
 
 static struct connman_session_policy session_policy_ivi = {
-- 
1.7.12.1.382.gb0576a6

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to