utils: use memmove when src and dst can overlap

spa_json_parse_stringn() can be used when the strings source and
destination are overlapping so use memmove instead of strncpy to
avoid corruption of the strings.
This commit is contained in:
Wim Taymans 2024-03-18 16:32:30 +01:00
parent ce86b9a398
commit c52c56621d

View file

@ -339,7 +339,7 @@ static inline int spa_json_parse_stringn(const char *val, int len, char *result,
return -1;
if (!spa_json_is_string(val, len)) {
if (result != val)
strncpy(result, val, len);
memmove(result, val, len);
result += len;
} else {
for (p = val+1; p < val + len; p++) {