mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
StringUtils: fix a possible segfault
This commit is contained in:
parent
fae8d1dd10
commit
c081268b7c
@ -83,7 +83,7 @@ static inline bool ffCharIsDigit(char c)
|
||||
// Copies at most (dstBufSiz - 1) bytes from src to dst; dst is always null-terminated
|
||||
static inline char* ffStrCopy(char* __restrict__ dst, const char* __restrict__ src, size_t dstBufSiz)
|
||||
{
|
||||
if (__builtin_expect(dst == NULL, false)) return dst;
|
||||
if (__builtin_expect(dst == NULL, false) || dstBufSiz == 0) return dst;
|
||||
|
||||
size_t len = strnlen(src, dstBufSiz - 1);
|
||||
memcpy(dst, src, len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user