From e1bc0f42fa5d474ba153672ee33f2ddc004dd15b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 16 Oct 2015 20:44:31 +0100 Subject: coverity#1327443 Division or modulo by zero Change-Id: Iefddcc2d66e77e3698dec9930898f63e0b7902f6 --- dbaccess/source/ui/dlg/paramdialog.cxx | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index ef8f0cc43a28..7a3769df11d1 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -263,25 +263,27 @@ namespace dbaui } else if (m_pTravelNext == pButton) { - sal_Int32 nCurrent = m_pAllParams->GetSelectEntryPos(); - sal_Int32 nCount = m_pAllParams->GetEntryCount(); - OSL_ENSURE(static_cast(nCount) == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !"); + if (sal_Int32 nCount = m_pAllParams->GetEntryCount()) + { + sal_Int32 nCurrent = m_pAllParams->GetSelectEntryPos(); + OSL_ENSURE(static_cast(nCount) == m_aVisitedParams.size(), "OParameterDialog::OnButtonClicked : inconsistent lists !"); - // search the next entry in list we haven't visited yet - sal_Int32 nNext = (nCurrent + 1) % nCount; - while ((nNext != nCurrent) && ( m_aVisitedParams[nNext] & EF_VISITED )) - nNext = (nNext + 1) % nCount; + // search the next entry in list we haven't visited yet + sal_Int32 nNext = (nCurrent + 1) % nCount; + while ((nNext != nCurrent) && ( m_aVisitedParams[nNext] & EF_VISITED )) + nNext = (nNext + 1) % nCount; - if ( m_aVisitedParams[nNext] & EF_VISITED ) - // there is no such "not visited yet" entry -> simply take the next one - nNext = (nCurrent + 1) % nCount; + if ( m_aVisitedParams[nNext] & EF_VISITED ) + // there is no such "not visited yet" entry -> simply take the next one + nNext = (nCurrent + 1) % nCount; - m_pAllParams->SelectEntryPos(nNext); - OnEntrySelected(); - m_bNeedErrorOnCurrent = true; - // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, - // so the next time it is called we need an error message, again .... - // (TODO : there surely are better solutions for this ...) + m_pAllParams->SelectEntryPos(nNext); + OnEntrySelected(); + m_bNeedErrorOnCurrent = true; + // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now, + // so the next time it is called we need an error message, again .... + // (TODO : there surely are better solutions for this ...) + } } } -- cgit v1.2.3