[libc][Obvious] Fix an off-by-one error introduced by eb9cc253cb048b6dbf2fcd73ac55b5e...
authorSiva Chandra Reddy <sivachandra@google.com>
Wed, 21 Dec 2022 21:10:42 +0000 (21:10 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Wed, 21 Dec 2022 21:11:08 +0000 (21:11 +0000)
libc/src/string/strndup.cpp

index 9a8d414..bf766e7 100644 (file)
@@ -24,7 +24,7 @@ LLVM_LIBC_FUNCTION(char *, strndup, (const char *src, size_t size)) {
   if (len > size)
     len = size;
   AllocChecker ac;
-  char *dest = new (ac) char[len];
+  char *dest = new (ac) char[len + 1];
   if (!ac)
     return nullptr;
   inline_memcpy(dest, src, len + 1);