From 233b75e8546b76b4f5ee5cec2ab0a99c90e5a3f0 Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 16 May 2026 15:38:19 +0200 Subject: [PATCH] fix: string_replace_at check malloc --- src/string.c | 4 ++++ 1 file changed, 4 insertions(+) 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);