Skip to content

Commit c081268

Browse files
committed
StringUtils: fix a possible segfault
1 parent fae8d1d commit c081268

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/util/stringUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static inline bool ffCharIsDigit(char c)
8383
// Copies at most (dstBufSiz - 1) bytes from src to dst; dst is always null-terminated
8484
static inline char* ffStrCopy(char* __restrict__ dst, const char* __restrict__ src, size_t dstBufSiz)
8585
{
86-
if (__builtin_expect(dst == NULL, false)) return dst;
86+
if (__builtin_expect(dst == NULL, false) || dstBufSiz == 0) return dst;
8787

8888
size_t len = strnlen(src, dstBufSiz - 1);
8989
memcpy(dst, src, len);

0 commit comments

Comments
 (0)