about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/strnlen.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sysdeps/generic/strnlen.c b/sysdeps/generic/strnlen.c
index f1b6760247..1386acfd9c 100644
--- a/sysdeps/generic/strnlen.c
+++ b/sysdeps/generic/strnlen.c
@@ -36,6 +36,9 @@ __strnlen (const char *str, size_t maxlen)
   if (maxlen == 0)
     return 0;
 
+  if (__builtin_expect (end_ptr < str, 0))
+    end_ptr = (const char *) ~0UL;
+
   /* Handle the first few characters by reading one character at a time.
      Do this until CHAR_PTR is aligned on a longword boundary.  */
   for (char_ptr = str; ((unsigned long int) char_ptr