diff --git a/src/ChangeLog b/src/ChangeLog index f1291b24..9d6659e8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-11-23 Hrvoje Niksic + + * progress.c (bar_update): If the downloaded amount becomes larger + than the expected amount, adjust the expected amount accordingly. + 2001-11-23 Hrvoje Niksic * utils.c (determine_screen_width): New function. diff --git a/src/progress.c b/src/progress.c index fc7ced31..518ec48e 100644 --- a/src/progress.c +++ b/src/progress.c @@ -397,6 +397,13 @@ bar_update (void *progress, long howmuch) long dltime = wtimer_elapsed (bp->timer); bp->count += howmuch; + if (bp->count + bp->initial_length > bp->total_length) + /* We could be downloading more than total_length, e.g. when the + server sends an incorrect Content-Length header. In that case, + 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; if (screen_width != bp->width) {