From 48ec829c7429825ac99a0d0911bfea58620eb506 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Tue, 19 Dec 2017 11:46:49 +0100 Subject: [PATCH] Do not move memory to itself To move the memory is only needed, when the memory is really freshly allocated. --- src/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.c b/src/utils.c index c79d06d..eff2f78 100644 --- a/src/utils.c +++ b/src/utils.c @@ -29,9 +29,9 @@ char *string_replace_at(char *buf, int pos, int len, const char *repl) tmp = buf; } else { tmp = g_malloc(size); + memcpy(tmp, buf, pos); } - memcpy(tmp, buf, pos); memcpy(tmp + pos, repl, repl_len); memmove(tmp + pos + repl_len, buf + pos + len, buf_len - (pos + len) + 1);