Handle case where config hasn't yet been read better.
authorLinus Nordberg <linus@nordberg.se>
Wed, 23 Jan 2013 15:18:26 +0000 (16:18 +0100)
committerLinus Nordberg <linus@nordberg.se>
Wed, 23 Jan 2013 17:20:24 +0000 (18:20 +0100)
Don't segfault is a good start.

lib/conf.c

index 14b7579..8ad0a45 100644 (file)
@@ -241,9 +241,11 @@ struct rs_realm *
 rs_conf_find_realm(struct rs_context *ctx, const char *name)
 {
   struct rs_realm *r;
+  assert (ctx);
 
-  for (r = ctx->config->realms; r; r = r->next)
-    if (strcmp (r->name, name) == 0)
+  if (ctx->config)
+    for (r = ctx->config->realms; r; r = r->next)
+      if (strcmp (r->name, name) == 0)
        return r;
 
   return NULL;