mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
xstrsncpy: allow 0 len copies to be no-ops
This commit is contained in:
parent
da73d9ada9
commit
a0c06d0843
|
@ -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 */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue