From 88e1b0215b27c8897ca66509fa08b96d86023ef7 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Sat, 11 Oct 2014 16:58:11 +0100 Subject: coverity#735605 Division or modulo by zero Change-Id: Ic3680ae833ed325ff4afe96fdca02f784ccd7d71 --- connectivity/source/drivers/dbase/DTable.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'connectivity') 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 : -- cgit