]> granicus.if.org Git - apache/commitdiff
Added a check to make sure that h_aliases is not NULL before we try to
authorBradley Nicholes <bnicholes@apache.org>
Fri, 26 Apr 2002 21:55:41 +0000 (21:55 +0000)
committerBradley Nicholes <bnicholes@apache.org>
Fri, 26 Apr 2002 21:55:41 +0000 (21:55 +0000)
dereference it in the for(...) loop.  Attempting to dereference a NULL pointer
was causing a fault if there were no aliases found.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@94819 13f79535-47bb-0310-9956-ffa450edef68

server/util.c

index 85bb37040377c404a3dafc663065ce8a52b703e1..22a7db7d41980bf98f668746abc43d3f6779495c 100644 (file)
@@ -1798,12 +1798,14 @@ static char *find_fqdn(apr_pool_t *a, struct hostent *p)
     int x;
 
     if (!strchr(p->h_name, '.')) {
-       for (x = 0; p->h_aliases[x]; ++x) {
-           if (strchr(p->h_aliases[x], '.') &&
-               (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
-               return apr_pstrdup(a, p->h_aliases[x]);
-       }
-       return NULL;
+        if (p->h_aliases) {
+            for (x = 0; p->h_aliases[x]; ++x) {
+                if (strchr(p->h_aliases[x], '.') &&
+                    (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
+                    return apr_pstrdup(a, p->h_aliases[x]);
+            }
+        }
+        return NULL;
     }
     return apr_pstrdup(a, (void *) p->h_name);
 }