]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Handle zero-length arguments specially.
authorUlrich Drepper <drepper@redhat.com>
Tue, 29 Jan 2002 03:44:02 +0000 (03:44 +0000)
committerUlrich Drepper <drepper@redhat.com>
Tue, 29 Jan 2002 03:44:02 +0000 (03:44 +0000)
string/strcoll.c

index f22bd101b2a803cb7ba8e463b5f18dcff111d1d8..0f3bd20a7945dddb6027f7c041973240a5a1e0cf 100644 (file)
@@ -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 <drepper@cygnus.com>, 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;