From: Ulrich Drepper Date: Tue, 29 Jan 2002 03:44:02 +0000 (+0000) Subject: Handle zero-length arguments specially. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=597d127a79bc6df4c6d97d832b9829532a50eb68;p=thirdparty%2Fglibc.git Handle zero-length arguments specially. --- diff --git a/string/strcoll.c b/string/strcoll.c index f22bd101b2a..0f3bd20a794 100644 --- a/string/strcoll.c +++ b/string/strcoll.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995,96,97,98,99,2000,2001 Free Software Foundation, Inc. +/* Copyright (C) 1995,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Ulrich Drepper , 1995. @@ -137,6 +137,10 @@ STRCOLL (s1, s2, l) s1len = STRLEN (s1); s2len = STRLEN (s2); + /* Catch empty strings. */ + if (__builtin_expect (s1len == 0, 0) || __builtin_expect (s2len == 0, 0)) + return (s1len != 0) - (s2len != 0); + /* We need the elements of the strings as unsigned values since they are used as indeces. */ us1 = (const USTRING_TYPE *) s1;