diff --git a/src/string.c b/src/string.c index e63259e..6eb5e18 100644 --- a/src/string.c +++ b/src/string.c @@ -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);