From: Kevin Day Date: Fri, 9 Feb 2024 02:46:14 +0000 (-0600) Subject: Bugfix: The f_string_dynamic_strip_null() memmove()'s out of range. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=370fe971a47fb7048ede4b3f27f7f970a8b78f84;p=fll 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. --- 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;