fix: string_replace_at check malloc
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user