dbaccess/source/ui/dlg/dbwiz.cxx | 4 +- starmath/source/cursor.cxx | 75 ++++++++++++++++++++------------------- sw/source/core/doc/tblafmt.cxx | 2 - 3 files changed, 42 insertions(+), 39 deletions(-)
New commits: commit 31038459b576b5ef53c3ccadb1e2aee0e61d20ff Author: Caolán McNamara <caol...@redhat.com> Date: Thu Jun 2 15:22:05 2016 +0100 coverity#1362478 Explicit null dereferenced and coverity#1362479, coverity#1362480, coverity#1362481, coverity#1362482, coverity#1362483, coverity#1362485 Change-Id: Ia3a32b69bcbe5ac3e7cc50dacfa02e8bf1aab787 diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index 617e100..3baf5e1 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -16,53 +16,56 @@ void SmCursor::Move(OutputDevice* pDev, SmMovementDirection direction, bool bMoveAnchor){ SmCaretPosGraphEntry* NewPos = nullptr; - switch(direction){ + switch(direction) + { case MoveLeft: - { - NewPos = mpPosition->Left; + if (mpPosition) + NewPos = mpPosition->Left; OSL_ENSURE(NewPos, "NewPos shouldn't be NULL here!"); - }break; + break; case MoveRight: - { - NewPos = mpPosition->Right; + if (mpPosition) + NewPos = mpPosition->Right; OSL_ENSURE(NewPos, "NewPos shouldn't be NULL here!"); - }break; + break; case MoveUp: //Implementation is practically identical to MoveDown, except for a single if statement //so I've implemented them together and added a direction == MoveDown to the if statements. case MoveDown: - { - SmCaretLine from_line = SmCaretPos2LineVisitor(pDev, mpPosition->CaretPos).GetResult(), - best_line, //Best approximated line found so far - curr_line; //Current line - long dbp_sq = 0; //Distance squared to best line - for(auto &pEntry : *mpGraph) + if (mpPosition) { - //Reject it if it's the current position - if(pEntry->CaretPos == mpPosition->CaretPos) continue; - //Compute caret line - curr_line = SmCaretPos2LineVisitor(pDev, pEntry->CaretPos).GetResult(); - //Reject anything above if we're moving down - if(curr_line.GetTop() <= from_line.GetTop() && direction == MoveDown) continue; - //Reject anything below if we're moving up - if(curr_line.GetTop() + curr_line.GetHeight() >= from_line.GetTop() + from_line.GetHeight() - && direction == MoveUp) continue; - //Compare if it to what we have, if we have anything yet - if(NewPos){ - //Compute distance to current line squared, multiplied with a horizontal factor - long dp_sq = curr_line.SquaredDistanceX(from_line) * HORIZONTICAL_DISTANCE_FACTOR + - curr_line.SquaredDistanceY(from_line); - //Discard current line if best line is closer - if(dbp_sq <= dp_sq) continue; + SmCaretLine from_line = SmCaretPos2LineVisitor(pDev, mpPosition->CaretPos).GetResult(), + best_line, //Best approximated line found so far + curr_line; //Current line + long dbp_sq = 0; //Distance squared to best line + for(auto &pEntry : *mpGraph) + { + //Reject it if it's the current position + if(pEntry->CaretPos == mpPosition->CaretPos) continue; + //Compute caret line + curr_line = SmCaretPos2LineVisitor(pDev, pEntry->CaretPos).GetResult(); + //Reject anything above if we're moving down + if(curr_line.GetTop() <= from_line.GetTop() && direction == MoveDown) continue; + //Reject anything below if we're moving up + if(curr_line.GetTop() + curr_line.GetHeight() >= from_line.GetTop() + from_line.GetHeight() + && direction == MoveUp) continue; + //Compare if it to what we have, if we have anything yet + if(NewPos){ + //Compute distance to current line squared, multiplied with a horizontal factor + long dp_sq = curr_line.SquaredDistanceX(from_line) * HORIZONTICAL_DISTANCE_FACTOR + + curr_line.SquaredDistanceY(from_line); + //Discard current line if best line is closer + if(dbp_sq <= dp_sq) continue; + } + //Take current line as the best + best_line = curr_line; + NewPos = pEntry.get(); + //Update distance to best line + dbp_sq = best_line.SquaredDistanceX(from_line) * HORIZONTICAL_DISTANCE_FACTOR + + best_line.SquaredDistanceY(from_line); } - //Take current line as the best - best_line = curr_line; - NewPos = pEntry.get(); - //Update distance to best line - dbp_sq = best_line.SquaredDistanceX(from_line) * HORIZONTICAL_DISTANCE_FACTOR + - best_line.SquaredDistanceY(from_line); } - }break; + break; default: SAL_WARN("starmath", "Movement direction not supported!"); } commit 7cf46388e4e0a9e6e59e1321c46c62801dde5ee2 Author: Caolán McNamara <caol...@redhat.com> Date: Thu Jun 2 15:13:51 2016 +0100 coverity#1362486 Unchecked dynamic_cast Change-Id: Ia495ac1434500048ce2f6ffd8d85e3ece13d2bad diff --git a/dbaccess/source/ui/dlg/dbwiz.cxx b/dbaccess/source/ui/dlg/dbwiz.cxx index 012d73e..06ce8f6 100644 --- a/dbaccess/source/ui/dlg/dbwiz.cxx +++ b/dbaccess/source/ui/dlg/dbwiz.cxx @@ -89,8 +89,8 @@ ODbTypeWizDialog::ODbTypeWizDialog(vcl::Window* _pParent m_pFinish->SetHelpId(HID_DBWIZ_FINISH); // no local resources needed anymore - const DbuTypeCollectionItem* pCollectionItem = dynamic_cast<const DbuTypeCollectionItem*>( _pItems->GetItem(DSID_TYPECOLLECTION) ); - m_pCollection = pCollectionItem->getCollection(); + const DbuTypeCollectionItem& rCollectionItem = dynamic_cast<const DbuTypeCollectionItem&>(*_pItems->GetItem(DSID_TYPECOLLECTION)); + m_pCollection = rCollectionItem.getCollection(); ActivatePage(); setTitleBase(ModuleRes(STR_DATABASE_TYPE_CHANGE)); commit da220c87700064f83c1312148531a9c0fdff4aa3 Author: Caolán McNamara <caol...@redhat.com> Date: Thu Jun 2 15:10:01 2016 +0100 coverity#1362484 Dereference after null check maybe this is what was wanted, still looks a bit dubious, won't crash straight away at least Change-Id: I1be934af9d7ec95f3a7079f2f34a3e3661311944 diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx index 229e9c95..1344b13 100644 --- a/sw/source/core/doc/tblafmt.cxx +++ b/sw/source/core/doc/tblafmt.cxx @@ -700,7 +700,7 @@ SwBoxAutoFormat& SwTableAutoFormat::GetBoxFormat( sal_uInt8 nPos ) // If default doesn't exist yet: if( !pDfltBoxAutoFormat ) pDfltBoxAutoFormat = new SwBoxAutoFormat(); - *pFormat = *pDfltBoxAutoFormat; + pFormat = pDfltBoxAutoFormat; } return *pFormat; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits