mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Handle failures when loading connection history.
This commit is contained in:
parent
57bd63dab6
commit
6c6ec00251
@ -15,20 +15,25 @@ ConnectionHistory::ConnectionHistory()
|
|||||||
if( !f ) return;
|
if( !f ) return;
|
||||||
|
|
||||||
uint64_t sz;
|
uint64_t sz;
|
||||||
fread( &sz, 1, sizeof( sz ), f );
|
if( fread( &sz, 1, sizeof( sz ), f ) != sizeof( sz ) ) goto err;
|
||||||
for( uint64_t i=0; i<sz; i++ )
|
for( uint64_t i=0; i<sz; i++ )
|
||||||
{
|
{
|
||||||
uint64_t ssz, cnt;
|
uint64_t ssz, cnt;
|
||||||
fread( &ssz, 1, sizeof( ssz ), f );
|
if( fread( &ssz, 1, sizeof( ssz ), f ) != sizeof( ssz ) ) goto err;
|
||||||
assert( ssz < 1024 );
|
if( ssz >= 1024 ) goto err;
|
||||||
char tmp[1024];
|
char tmp[1024];
|
||||||
fread( tmp, 1, ssz, f );
|
if( fread( tmp, 1, ssz, f ) != ssz ) goto err;
|
||||||
fread( &cnt, 1, sizeof( cnt ), f );
|
if( fread( &cnt, 1, sizeof( cnt ), f ) != sizeof( cnt ) ) goto err;
|
||||||
m_connHistMap.emplace( std::string( tmp, tmp+ssz ), cnt );
|
m_connHistMap.emplace( std::string( tmp, tmp+ssz ), cnt );
|
||||||
}
|
}
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
|
||||||
Rebuild();
|
Rebuild();
|
||||||
|
return;
|
||||||
|
|
||||||
|
err:
|
||||||
|
fclose( f );
|
||||||
|
m_connHistMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionHistory::~ConnectionHistory()
|
ConnectionHistory::~ConnectionHistory()
|
||||||
|
Loading…
Reference in New Issue
Block a user