]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
[Bug 381] Str.h assert problem
authorDarren Nickerson <darren.nickerson@ifax.com>
Sun, 9 Feb 2003 02:36:26 +0000 (02:36 +0000)
committerDarren Nickerson <darren.nickerson@ifax.com>
Sun, 9 Feb 2003 02:36:26 +0000 (02:36 +0000)
Patch to fix topDomain subroutine contributed by John Gilman.

hfaxd/InetFaxServer.c++

index b90cdf4d85780de0bb600fe55b9eebc405296f13..39c8fd30d403a2c59c2c42ecd5dd1db588244f92 100644 (file)
@@ -126,18 +126,19 @@ InetFaxServer::open(void)
 static const char*
 topDomain(const fxStr& h)
 {
-    char* maybe = NULL;
     int dots = 0;
     u_int l = h.length();
+
+    if(l <= 0) return(NULL);  // out early
+
     for (;;) {
        l = h.nextR(l, '.');
        if (l == 0)
-           break;
+           return (&h[0]);  // return whole string
        if (++dots == 2)
            return (&h[l]);
-       maybe = &h[l];
+       l -=1;    //back over the dot
     }
-    return (maybe);
 }
 
 /*