From: Paul Floyd Date: Mon, 25 Dec 2023 08:00:26 +0000 (+0100) Subject: Darwin regtest: memmem returns NULL if either length is 0. X-Git-Tag: VALGRIND_3_23_0~217 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e7a9921c8f021b5301a7e93eb64b01326275409a;p=thirdparty%2Fvalgrind.git Darwin regtest: memmem returns NULL if either length is 0. --- diff --git a/memcheck/tests/memmem.c b/memcheck/tests/memmem.c index 7cefafcc65..41dc0fa3db 100644 --- a/memcheck/tests/memmem.c +++ b/memcheck/tests/memmem.c @@ -2,6 +2,7 @@ #include #include #include +#include "../../config.h" /* mallocs an mem block and fills it with A. A needs to be a zero terminated string. The A string chars, minus the terminating zero @@ -23,7 +24,17 @@ main () haystack = create_mem ("a"); needle = create_mem ("a"); +#if defined(VGO_darwin) + /* + * macOS manpage says + * If big_len is smaller than little_len, if little_len is 0, if big_len is 0 or if + * little occurs nowhere in big, NULL is returned; otherwise a pointer to the first + * character of the first occurrence of little is returned. + */ + assert (memmem (haystack, 0, needle, 0) == NULL); +#else assert (memmem (haystack, 0, needle, 0) == haystack); +#endif assert (memmem (haystack, 1, needle, 0) == haystack); assert (memmem (haystack, 0, needle, 1) == NULL); assert (memmem (haystack, 1, needle, 1) == haystack);