From 39962e28d08da413853d9209f2b5dc46a394c5d8 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 20 Dec 2007 10:11:37 +0000 Subject: [PATCH] * libc/memmem.cc (memmem): Fix bug when searching for empty string. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/libc/memmem.cc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fdd0298ec..afa9c9e69 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2007-12-20 Eric Blake + + * libc/memmem.cc (memmem): Fix bug when searching for empty string. + 2007-12-19 Corinna Vinschen * cygwin.din: Export wcpcpy, wcpncpy. diff --git a/winsup/cygwin/libc/memmem.cc b/winsup/cygwin/libc/memmem.cc index cd9dc33d3..142b73333 100644 --- a/winsup/cygwin/libc/memmem.cc +++ b/winsup/cygwin/libc/memmem.cc @@ -45,8 +45,8 @@ memmem (const void *l, size_t l_len, const char *cs = (const char *)s; /* we need something to compare */ - if (l_len == 0 || s_len == 0) - return NULL; + if (s_len == 0) + return (void *) l; /* "s" must be smaller or equal to "l" */ if (l_len < s_len)