diff --git a/source/shell/progress.c b/source/shell/progress.c index 145dbc3..9c58384 100644 --- a/source/shell/progress.c +++ b/source/shell/progress.c @@ -4,12 +4,16 @@ void draw_progress(FILE *fp, unsigned long pos, unsigned long max) { - unsigned long head = (TERM_WIDTH - 2) * pos / max; - unsigned long i; + unsigned long head, i; + + if (pos > max) + pos = max; + + head = (TERM_WIDTH - 2) * pos / max; fputc('[', fp); - for (i = 0; i <= head; ++i) + for (i = 0; i < head; ++i) fputc('#', fp); for (; i < (TERM_WIDTH - 2); ++i)