replace: allow memmem() with an empty string to return NULL
authorAndrew Tridgell <tridge@samba.org>
Tue, 30 Mar 2010 07:12:46 +0000 (18:12 +1100)
committerAndrew Tridgell <tridge@samba.org>
Tue, 30 Mar 2010 09:34:17 +0000 (20:34 +1100)
This is how FreeBSD behaves. We don't rely on it returning the string
in Samba.

lib/replace/test/testsuite.c

index 829e9f9c1d7cf2ed63789b2b7f09d23f55265e92..46697b5f19d08fd31d623fce4fba20d2712713ed 100644 (file)
@@ -1027,7 +1027,9 @@ static int test_memmem(void)
        }
 
        s = memmem("foo", 3, "", 0);
-       if (strcmp(s, "foo") != 0) {
+       /* it is allowable for this to return NULL (as happens on
+          FreeBSD) */
+       if (s && strcmp(s, "foo") != 0) {
                printf(__location__ ": Failed memmem\n");
                return false;
        }