]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - libiberty/xstrndup.c
Set development mode to "off" by default.
[thirdparty/binutils-gdb.git] / libiberty / xstrndup.c
index 0a41f608ec0b9c71ddebc4975c688c88bdde30a3..32ba832427cfe0f5c6cbdf0ced4bc0150a168c8f 100644 (file)
@@ -1,5 +1,5 @@
 /* Implement the xstrndup function.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005-2020 Free Software Foundation, Inc.
    Written by Kaveh R. Ghazi <ghazi@caip.rutgers.edu>.
 
 This file is part of the libiberty library.
@@ -48,10 +48,7 @@ char *
 xstrndup (const char *s, size_t n)
 {
   char *result;
-  size_t len = strlen (s);
-
-  if (n < len)
-    len = n;
+  size_t len = strnlen (s, n);
 
   result = XNEWVEC (char, len + 1);