fix bug wihen downloading multiple chunks

if the second chunk failed, but the first one downloaded properly, an invalid buffer was supplied