commit a0c06d0843a7dd8c8e2603913cd0d33c1efa78ea
parent da73d9ada93788bad37eb4648dfa2a0ac92c56ed
Author: NRK <nrk@disroot.org>
Date: Sun, 5 Jan 2025 19:17:18 +0000
xstrsncpy: allow 0 len copies to be no-ops
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -988,7 +988,8 @@ static size_t xstrsncpy(char *restrict dst, const char *restrict src, size_t n)
char *end = memccpy(dst, src, '\0', n);
if (!end) {
- dst[n - 1] = '\0'; // NOLINT
+ if (n)
+ dst[n - 1] = '\0';
end = dst + n; /* If we return n here, binary size increases due to auto-inlining */
}