[libc-commits] [libc] b5415f3 - [libc][Obvious] Fix an off-by-one error introduced by eb9cc253cb048b6dbf2fcd73ac55b5eda0184ed3.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Wed Dec 21 13:13:40 PST 2022
Author: Siva Chandra Reddy
Date: 2022-12-21T21:11:08Z
New Revision: b5415f301586b74f729bee20fcfb34066413dbb5
URL: https://github.com/llvm/llvm-project/commit/b5415f301586b74f729bee20fcfb34066413dbb5
DIFF: https://github.com/llvm/llvm-project/commit/b5415f301586b74f729bee20fcfb34066413dbb5.diff
LOG: [libc][Obvious] Fix an off-by-one error introduced by eb9cc253cb048b6dbf2fcd73ac55b5eda0184ed3.
Added:
Modified:
libc/src/string/strndup.cpp
Removed:
################################################################################
diff --git a/libc/src/string/strndup.cpp b/libc/src/string/strndup.cpp
index 9a8d414c76bc9..bf766e701586f 100644
--- a/libc/src/string/strndup.cpp
+++ b/libc/src/string/strndup.cpp
@@ -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);
More information about the libc-commits
mailing list