Andreas Schwab wrote:
> Jim Meyering <j...@meyering.net> writes:
>> cat > k.c <<\EOF
>> #include <string.h>
>> int main() { return !!(memchr (0, 'a', 0)); }
>> EOF
>> gcc -O k.c; ./a.out
>> Segmentation fault
>> [Exit 139 (SIGSEGV)]
>
> This is not a bug.  NULL is not a valid object pointer.

It may not be a POSIX conformance issue when using NULL (if you're
convinced it is, please explain why), but even if that is, it's just a
technicality.  When the specified length is 0, memchr must not dereference
the pointer.  I could have used a pointer to an object that happens to
be unreadable.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to