error handling fixes

This commit is contained in:
Arvid Norberg 2008-01-16 21:07:04 +00:00
parent 832c0c8b63
commit c69fa07e2d
2 changed files with 5 additions and 2 deletions

View File

@ -86,7 +86,7 @@ namespace libtorrent
BN_bn2bin(m_DH->pub_key, (unsigned char*)m_dh_local_key); // TODO Check return value BN_bn2bin(m_DH->pub_key, (unsigned char*)m_dh_local_key); // TODO Check return value
} }
DH_key_exchange::~DH_key_exchange () DH_key_exchange::~DH_key_exchange()
{ {
TORRENT_ASSERT(m_DH); TORRENT_ASSERT(m_DH);
DH_free(m_DH); DH_free(m_DH);
@ -108,6 +108,7 @@ namespace libtorrent
int secret_size = DH_compute_key((unsigned char*)dh_secret int secret_size = DH_compute_key((unsigned char*)dh_secret
, bn_remote_pubkey, m_DH); , bn_remote_pubkey, m_DH);
if (secret_size < 0 || secret_size > 96) throw std::bad_alloc();
if (secret_size != 96) if (secret_size != 96)
{ {
@ -139,3 +140,4 @@ namespace libtorrent
} // namespace libtorrent } // namespace libtorrent
#endif // #ifndef TORRENT_DISABLE_ENCRYPTION #endif // #ifndef TORRENT_DISABLE_ENCRYPTION

View File

@ -1789,7 +1789,8 @@ namespace libtorrent
INVARIANT_CHECK; INVARIANT_CHECK;
boost::shared_ptr<torrent> t = m_torrent.lock(); boost::shared_ptr<torrent> t = m_torrent.lock();
TORRENT_ASSERT(t); // this peer might be disconnecting
if (!t) return;
TORRENT_ASSERT(t->valid_metadata()); TORRENT_ASSERT(t->valid_metadata());