From 5eb3d67a1e2b92485f0058eb59b94bc3296bdb90 Mon Sep 17 00:00:00 2001 From: dg Date: Fri, 25 Nov 1994 08:58:53 +0000 Subject: Go back to Bruce's fix with a minor change that will allow a NULL string pointer if len is 0. I should have looked at the revision history - I would have found that Bruce already fixed the bug with len=0 over a month ago. Whoever said that the bug was in 2.0 was wrong. --- lib/libc/i386/string/memchr.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/libc/i386/string') diff --git a/lib/libc/i386/string/memchr.S b/lib/libc/i386/string/memchr.S index a1b2bcc..621a7fb 100644 --- a/lib/libc/i386/string/memchr.S +++ b/lib/libc/i386/string/memchr.S @@ -27,11 +27,11 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: memchr.S,v 1.2 1994/10/27 11:36:11 bde Exp $ + * $Id: memchr.S,v 1.3 1994/11/25 04:11:19 davidg Exp $ */ #if defined(LIBC_RCS) && !defined(lint) - .asciz "$Id: memchr.S,v 1.2 1994/10/27 11:36:11 bde Exp $" + .asciz "$Id: memchr.S,v 1.3 1994/11/25 04:11:19 davidg Exp $" #endif /* LIBC_RCS and not lint */ #include "DEFS.h" @@ -49,8 +49,7 @@ ENTRY(memchr) movl 8(%esp),%edi /* string address */ movl 12(%esp),%eax /* set character to search for */ movl 16(%esp),%ecx /* set length of search */ - testl %ecx,%ecx /* return NULL if len == 0 */ - jz L1 + testl %esp,%esp /* clear Z flag, for len == 0 */ cld /* set search forward */ repne /* search! */ scasb -- cgit v1.1