Checkpoint commit: refactoring the request code in TIDS for better reuse
[trust_router.git] / common / tr_idp.c
index f6c0836..747397b 100644 (file)
@@ -35,7 +35,7 @@
 #include <talloc.h>
 #include <time.h>
 
-#include <trust_router/tr_name.h>
+#include <tr_name_internal.h>
 #include <tr_idp.h>
 #include <tr_config.h>
 #include <tr_debug.h>
@@ -345,11 +345,11 @@ char *tr_idp_realm_to_str(TALLOC_CTX *mem_ctx, TR_IDP_REALM *idp)
   }
 
   result=talloc_asprintf(mem_ctx,
-                         "IDP realm: \"%.*s\"\n"
-                         "  shared: %s\n"
-                         "  local: %s\n"
-                         "  AAA servers: %s\n"
-                         "  APCs: %s\n",
+                         "IDP realm: \"%.*s\""
+                         "  shared: %s"
+                         "  local: %s"
+                         "  AAA servers: %s"
+                         "  APCs: %s",
                          idp->realm_id->len, idp->realm_id->buf,
                          (idp->shared_config)?"yes":"no",
                          (idp->origin==TR_REALM_LOCAL)?"yes":"no",
@@ -389,11 +389,11 @@ TR_IDP_REALM *tr_idp_realm_sweep_func(TR_IDP_REALM *head)
   if (head==NULL)
     return NULL;
 
-  /* will not remove the head here, that has already been done */
-  for (idp=head; idp->next!=NULL; idp=idp->next) {
+  /* Will not remove the head here, that has already been done.*/
+  for (idp=head; (idp!=NULL) && (idp->next!=NULL); idp=idp->next) {
     if (idp->next->refcount==0) {
       old_next=idp->next;
-      tr_idp_realm_remove(head, idp->next); /* changes idp->next */
+      tr_idp_realm_remove(head, idp->next); /* changes idp->next, may make it NULL */
       tr_idp_realm_free(old_next);
     }
   }