chiark / gitweb /
bus-proxyd: do not free NULL items
[elogind.git] / src / bus-proxyd / bus-policy.c
index c592f501bf3d1d98a547e34806efd161f7a6741e..053495cebe7c13a8ea98e26a6bb5c2b181838935 100644 (file)
@@ -212,6 +212,7 @@ static int file_load(Policy *p, const char *path) {
                                 free(policy_user);
                                 policy_user = name;
                                 name = NULL;
+                                policy_category = POLICY_CATEGORY_USER;
                                 state = STATE_POLICY;
                         } else {
                                 log_error("Unexpected token (5) in %s:%u.", path, line);
@@ -226,6 +227,7 @@ static int file_load(Policy *p, const char *path) {
                                 free(policy_group);
                                 policy_group = name;
                                 name = NULL;
+                                policy_category = POLICY_CATEGORY_GROUP;
                                 state = STATE_POLICY;
                         } else {
                                 log_error("Unexpected token (6) at %s:%u.", path, line);
@@ -555,8 +557,6 @@ void policy_free(Policy *p) {
                         LIST_REMOVE(items, first, i);
                         policy_item_free(i);
                 }
-
-                policy_item_free(i);
         }
 
         while ((first = hashmap_steal_first(p->group_items))) {
@@ -565,8 +565,6 @@ void policy_free(Policy *p) {
                         LIST_REMOVE(items, first, i);
                         policy_item_free(i);
                 }
-
-                policy_item_free(i);
         }
 
         hashmap_free(p->user_items);
@@ -636,15 +634,15 @@ static void dump_items(PolicyItem *i) {
 static void dump_hashmap_items(Hashmap *h) {
         PolicyItem *i;
         Iterator j;
-        char *k;
+        void *k;
 
         HASHMAP_FOREACH_KEY(i, k, h, j) {
-                printf("Item for %s", k);
+                printf("Item for %u:\n", PTR_TO_UINT(k));
                 dump_items(i);
         }
 }
 
-void policy_dump(Policy *p) {
+noreturn void policy_dump(Policy *p) {
 
         printf("→ Default Items:\n");
         dump_items(p->default_items);