added some extra checks for buffer overrun in disk_io_thread

This commit is contained in:
Arvid Norberg 2007-08-02 01:42:19 +00:00
parent 77481c24a7
commit 192ce4b463
2 changed files with 9 additions and 0 deletions

View File

@ -111,6 +111,10 @@ namespace libtorrent
// memory pool for read and write operations
boost::pool<> m_pool;
#ifndef NDEBUG
int m_block_size;
#endif
// thread for performing blocking disk io operations
boost::thread m_disk_io_thread;
};

View File

@ -41,6 +41,9 @@ namespace libtorrent
: m_abort(false)
, m_queue_buffer_size(0)
, m_pool(block_size)
#ifndef NDEBUG
, m_block_size(block_size)
#endif
, m_disk_io_thread(boost::ref(*this))
{}
@ -192,6 +195,7 @@ namespace libtorrent
}
else
{
assert(j.buffer_size <= m_block_size);
ret = j.storage->read_impl(j.buffer, j.piece, j.offset
, j.buffer_size);
@ -201,6 +205,7 @@ namespace libtorrent
break;
case disk_io_job::write:
assert(j.buffer);
assert(j.buffer_size <= m_block_size);
j.storage->write_impl(j.buffer, j.piece, j.offset
, j.buffer_size);