From 370fe971a47fb7048ede4b3f27f7f970a8b78f84 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Feb 2024 20:46:14 -0600 Subject: [PATCH] Bugfix: The f_string_dynamic_strip_null() memmove()'s out of range. The i is a position rather than the total count. Add 1 to the i. This will need unit tests written to better catch these problems. --- level_0/f_string/c/string/dynamic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/level_0/f_string/c/string/dynamic.c b/level_0/f_string/c/string/dynamic.c index 11acd72..8806fff 100644 --- a/level_0/f_string/c/string/dynamic.c +++ b/level_0/f_string/c/string/dynamic.c @@ -657,7 +657,7 @@ extern "C" { j = i; } - memmove(buffer->string + j, buffer->string + i + 1, buffer->used - i); + memmove(buffer->string + j, buffer->string + i + 1, buffer->used - (i + 1)); memset(buffer->string + (buffer->used - (i - j) - 1), 0, (i - j) + 1); buffer->used -= (i - j) + 1; -- 1.8.3.1