From 002442c41f7e0fffc23ae04cfd1d6aa119c10f2e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 10 Jul 2013 09:43:19 +0300 Subject: [PATCH] auth: Fixed crash for some lookups that didn't specify service name. --- src/auth/auth.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/auth/auth.c b/src/auth/auth.c index 292cdbd2cf..2c7dca4d1a 100644 --- a/src/auth/auth.c +++ b/src/auth/auth.c @@ -268,15 +268,17 @@ struct auth *auth_find_service(const char *name) unsigned int i, count; a = array_get(&auths, &count); - for (i = 1; i < count; i++) { - if (strcmp(a[i]->service, name) == 0) - return a[i]; - } - /* not found. maybe we can instead find a !service */ - for (i = 1; i < count; i++) { - if (a[i]->service[0] == '!' && - strcmp(a[i]->service + 1, name) != 0) - return a[i]; + if (name != NULL) { + for (i = 1; i < count; i++) { + if (strcmp(a[i]->service, name) == 0) + return a[i]; + } + /* not found. maybe we can instead find a !service */ + for (i = 1; i < count; i++) { + if (a[i]->service[0] == '!' && + strcmp(a[i]->service + 1, name) != 0) + return a[i]; + } } return a[0]; } -- 2.47.3