diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-10-11 16:58:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2014-10-11 17:33:52 +0100 |
commit | 88e1b0215b27c8897ca66509fa08b96d86023ef7 (patch) | |
tree | 420abf68e57fd11ebdb57661897907c764bb1e09 /connectivity | |
parent | 4e4080175abc712ce3e78c338cb8270cf2039cee (diff) |
coverity#735605 Division or modulo by zero
Change-Id: Ic3680ae833ed325ff4afe96fdca02f784ccd7d71
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index a98a54d0397b..4c1bf022d8bc 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -532,8 +532,14 @@ void ODbaseTable::construct() sal_Size nFileSize = lcl_getFileSize(*m_pFileStream); m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); - if ( m_aHeader.db_anz == 0 && ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng) > 0) // seems to be empty or someone wrote bullshit into the dbase file - m_aHeader.db_anz = ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng); + // seems to be empty or someone wrote bullshit into the dbase file + // try and recover if m_aHeader.db_slng is sane + if (m_aHeader.db_anz == 0 && m_aHeader.db_slng) + { + sal_Size nRecords = (nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng; + if (nRecords > 0) + m_aHeader.db_anz = nRecords; + } // Buffersize dependent on the file size m_pFileStream->SetBufferSize(nFileSize > 1000000 ? 32768 : |