From: Kevin Day Date: Sat, 11 Dec 2021 03:36:42 +0000 (-0600) Subject: Bugfix: Raw formatted print sometimes prints trailing NULL. X-Git-Tag: 0.5.7~56 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=09f504dc89205fa1163789cceae2704286e65950;p=fll Bugfix: Raw formatted print sometimes prints trailing NULL. A logic flaw is resulting in the last NULL after the max length is reached to be printed. When the strnlen() calculates the length and the calculated length is the requested max length, the subsequent line attempts to print any NULLs. This is normally fine, except that it needs to check to make sure that "i" is less than the requested max length. --- diff --git a/level_0/f_print/c/private-print.c b/level_0/f_print/c/private-print.c index 8251c4f..5ac1b10 100644 --- a/level_0/f_print/c/private-print.c +++ b/level_0/f_print/c/private-print.c @@ -522,7 +522,7 @@ extern "C" { } // Print all NULL characters. - if (!string[i]) { + if (i < length && !string[i]) { start = i; do {