fix the off-by-one errors in file_storage as well as a NULL conversion warning (typo)
This commit is contained in:
parent
56e4c48873
commit
92cedf82cf
@ -421,7 +421,7 @@ namespace libtorrent
|
||||
void file_storage::set_file_base(int index, size_type off)
|
||||
{
|
||||
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
|
||||
if (int(m_file_base.size()) <= index) m_file_base.resize(index);
|
||||
if (int(m_file_base.size()) <= index) m_file_base.resize(index + 1, 0);
|
||||
m_file_base[index] = off;
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ namespace libtorrent
|
||||
{
|
||||
int index = &fe - &m_files[0];
|
||||
TORRENT_ASSERT(index >= 0 && index < int(m_files.size()));
|
||||
if (int(m_file_base.size()) <= index) m_file_base.resize(index);
|
||||
if (int(m_file_base.size()) <= index) m_file_base.resize(index + 1, 0);
|
||||
m_file_base[index] = off;
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ namespace libtorrent
|
||||
if (!m_file_base.empty())
|
||||
{
|
||||
TORRENT_ASSERT(m_file_base.size() == m_files.size());
|
||||
if (int(m_file_base.size()) < index) m_file_base.resize(index + 1, NULL);
|
||||
if (int(m_file_base.size()) < index) m_file_base.resize(index + 1, 0);
|
||||
std::iter_swap(m_file_base.begin() + dst, m_file_base.begin() + index);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user