X-Git-Url: http://sjero.net/git/?p=wget;a=blobdiff_plain;f=src%2Fprogress.c;h=644c1b2b9dc1571bb3d3dbabbbc5c4bad27f6dbc;hp=de5d16a31cda85ae036ca51a362b2fa57be83ed6;hb=c77a16309f0d1903961f102d21917f2b882896a5;hpb=8f93191f2656768dee6f9f700b9653421df55e1c diff --git a/src/progress.c b/src/progress.c index de5d16a3..644c1b2b 100644 --- a/src/progress.c +++ b/src/progress.c @@ -461,6 +461,11 @@ bar_create (long initial, long total) memset (bp, 0, sizeof (*bp)); + /* In theory, our callers should take care of this pathological + case, but it can sometimes happen. */ + if (initial > total) + total = initial; + bp->initial_length = initial; bp->total_length = total; @@ -493,7 +498,7 @@ bar_update (void *progress, long howmuch, long dltime) adjust bp->total_length to the new reality, so that the code in create_image() that depends on total size being smaller or equal to the expected size doesn't abort. */ - bp->total_length = bp->count + bp->initial_length; + bp->total_length = bp->initial_length + bp->count; /* This code attempts to determine the current download speed. We measure the speed over the interval of approximately three @@ -565,6 +570,11 @@ bar_finish (void *progress, long dltime) { struct bar_progress *bp = progress; + if (bp->total_length > 0 + && bp->count + bp->initial_length > bp->total_length) + /* See bar_update() for explanation. */ + bp->total_length = bp->initial_length + bp->count; + create_image (bp, dltime); display_image (bp->buffer);