fix: string_replace_at check malloc

This commit is contained in:
2026-05-16 15:38:19 +02:00
parent 910c122c8d
commit 233b75e854
+4
View File
@@ -67,6 +67,10 @@ char *string_replace_at(const char *src, unsigned int from, unsigned int to,
dst = malloc(src_len - (to - from) + rpl_len + 1);
if (dst == NULL) {
return "";
}
strlcpy(dst, src, from + 1);
strlcpy(dst + from, rpl, rpl_len + 1);
strlcpy(dst + from + rpl_len, src + to, src_len - to + 1);