From: Samuel Dudik Date: Sun, 2 Aug 2020 17:29:13 +0000 (+0200) Subject: Fix bug with long words causing infinite loop X-Git-Url: https://git.datadissipation.net/herbe/commitdiff_plain/5cead86549c8ae489cc3fca2f1bc5512e0510d42 Fix bug with long words causing infinite loop --- diff --git a/herbe.c b/herbe.c index 5bcb0a1..f619c79 100644 --- a/herbe.c +++ b/herbe.c @@ -89,10 +89,15 @@ int main(int argc, char *argv[]) break; } - while (body[eols[num_of_lines - 1] + eol] != ' ') + int temp = eol; + + while (body[eols[num_of_lines - 1] + eol] != ' ' && eol) --eol; - eol++; + if (eol == 0) + eol = temp; + else + eol++; remainder -= eol; if (eols_size < num_of_lines + 1)