From 93894efe339664a9bf5ed19b13995bd3e8aabff7 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 23 Jan 2013 16:18:26 +0100 Subject: [PATCH] Handle case where config hasn't yet been read better. Don't segfault is a good start. --- lib/conf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/conf.c b/lib/conf.c index 14b7579..8ad0a45 100644 --- a/lib/conf.c +++ b/lib/conf.c @@ -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; -- 2.1.4