ident: handle NULL ai_canonname
[gitweb.git] / ident.c
diff --git a/ident.c b/ident.c
index 4fd82d104365c2e2c1ab7e1597e7e246c8eded24..28bc85491872704162c33fa7ac09460bc5b35a11 100644 (file)
--- a/ident.c
+++ b/ident.c
@@ -103,7 +103,7 @@ static int canonical_name(const char *host, struct strbuf *out)
        memset (&hints, '\0', sizeof (hints));
        hints.ai_flags = AI_CANONNAME;
        if (!getaddrinfo(host, NULL, &hints, &ai)) {
-               if (ai && strchr(ai->ai_canonname, '.')) {
+               if (ai && ai->ai_canonname && strchr(ai->ai_canonname, '.')) {
                        strbuf_addstr(out, ai->ai_canonname);
                        status = 0;
                }