From 67bfe9af61bbc034cb382c847190a0b6ef6471ec Mon Sep 17 00:00:00 2001 From: Josh Elsasser Date: Thu, 8 Mar 2007 06:04:47 +0000 Subject: [PATCH] Merge bitfield fix from r1548 to the trunk. --- libtransmission/fastresume.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libtransmission/fastresume.h b/libtransmission/fastresume.h index 20a7e6fe8..9b7ff4e0a 100644 --- a/libtransmission/fastresume.h +++ b/libtransmission/fastresume.h @@ -128,6 +128,7 @@ static void fastResumeSave( tr_io_t * io ) uint8_t * buf; uint64_t total; int size; + tr_bitfield_t * bitfield; buf = malloc( FR_PROGRESS_LEN( tor ) ); @@ -152,8 +153,9 @@ static void fastResumeSave( tr_io_t * io ) fwrite( &version, 4, 1, file ); /* Build and copy the bitfield for blocks */ - memcpy(buf + FR_MTIME_LEN( tor ), tr_cpBlockBitfield( tor->completion ), - FR_BLOCK_BITFIELD_LEN( tor ) ); + bitfield = tr_cpBlockBitfield( tor->completion ); + assert( FR_BLOCK_BITFIELD_LEN( tor ) == bitfield->len ); + memcpy(buf + FR_MTIME_LEN( tor ), bitfield->bits, bitfield->len ); /* Copy the 'slotPiece' table */ memcpy(buf + FR_MTIME_LEN( tor ) + FR_BLOCK_BITFIELD_LEN( tor ),