Make peakfile block scanning more robust.

This commit is contained in:
Jonathan Moore Liles 2008-05-11 18:28:08 -05:00
parent 50fa642321
commit 9b8e7569e7
1 changed files with 7 additions and 5 deletions

View File

@ -187,12 +187,15 @@ public:
std::list <block_descriptor> blocks; std::list <block_descriptor> blocks;
/* scan all blocks */ /* scan all blocks */
do for ( ;; )
{ {
peakfile_block_header bh; peakfile_block_header bh;
fread( &bh, sizeof( bh ), 1, _fp ); fread( &bh, sizeof( bh ), 1, _fp );
if ( feof( _fp ) )
break;
// printf( "chunksize=%lu, skip=%lu\n", (unsigned long)bh.chunksize, (unsigned long) bh.skip ); // printf( "chunksize=%lu, skip=%lu\n", (unsigned long)bh.chunksize, (unsigned long) bh.skip );
ASSERT( bh.chunksize, "Invalid peak file structure!" ); ASSERT( bh.chunksize, "Invalid peak file structure!" );
@ -209,7 +212,6 @@ public:
break; break;
} }
} }
while ( ! feof( _fp ) );
if ( ! blocks.size() ) if ( ! blocks.size() )
FATAL( "invalid peak file?" ); FATAL( "invalid peak file?" );