summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-04-06 23:31:55 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-04-07 13:52:51 +0200
commit3feb65096a5dbb2b9713293a997754f0257223b5 (patch)
treeab0f2bb30111a2f5133999328818d32574300839
parent55783b8006a509dbdfe29a1bd5d86f26204b6a42 (diff)
tdf#120703 PVS: Silence V522 warnings
V522 There might be dereferencing of a potential null pointer. Change-Id: I680f1628133216de6336ac5ffa846447ffd55a41 Reviewed-on: https://gerrit.libreoffice.org/70352 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--basic/source/runtime/dllmgr-x64.cxx18
-rw-r--r--basic/source/runtime/dllmgr-x86.cxx18
-rw-r--r--chart2/source/controller/dialogs/DialogModel.cxx1
-rw-r--r--sfx2/source/inet/inettbc.cxx1
-rw-r--r--svx/source/form/filtnav.cxx3
-rw-r--r--sw/source/core/layout/fly.cxx1
-rw-r--r--sw/source/core/undo/docundo.cxx14
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx6
8 files changed, 37 insertions, 25 deletions
diff --git a/basic/source/runtime/dllmgr-x64.cxx b/basic/source/runtime/dllmgr-x64.cxx
index 4c5973fdc919..a56aeee2726a 100644
--- a/basic/source/runtime/dllmgr-x64.cxx
+++ b/basic/source/runtime/dllmgr-x64.cxx
@@ -159,8 +159,9 @@ std::size_t alignment(SbxVariable const * variable) {
case SbxOBJECT:
{
std::size_t n = 1;
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
n = std::max(n, alignment(props->Get(i)));
}
@@ -175,6 +176,7 @@ std::size_t alignment(SbxVariable const * variable) {
}
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
for (int i = 0; i < dims; ++i) {
@@ -210,8 +212,9 @@ ErrCode marshalStruct(
MarshalData & data)
{
OSL_ASSERT(variable != nullptr);
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
ErrCode e = marshal(false, props->Get(i), false, blob, offset, data);
if (e != ERRCODE_NONE) {
@@ -227,6 +230,7 @@ ErrCode marshalArray(
{
OSL_ASSERT(variable != nullptr);
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
@@ -402,8 +406,9 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
align(
reinterpret_cast< sal_uIntPtr >(data),
alignment(variable)));
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
data = unmarshal(props->Get(i), data);
}
@@ -421,6 +426,7 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
}
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
diff --git a/basic/source/runtime/dllmgr-x86.cxx b/basic/source/runtime/dllmgr-x86.cxx
index 347f9ad4067d..74b470da2e04 100644
--- a/basic/source/runtime/dllmgr-x86.cxx
+++ b/basic/source/runtime/dllmgr-x86.cxx
@@ -166,8 +166,9 @@ std::size_t alignment(SbxVariable * variable) {
case SbxOBJECT:
{
std::size_t n = 1;
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
n = std::max(n, alignment(props->Get(i)));
}
@@ -182,6 +183,7 @@ std::size_t alignment(SbxVariable * variable) {
}
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
for (int i = 0; i < dims; ++i) {
@@ -218,8 +220,9 @@ ErrCode marshalStruct(
MarshalData & data)
{
OSL_ASSERT(variable != 0);
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
ErrCode e = marshal(false, props->Get(i), false, blob, offset, data);
if (e != ERRCODE_NONE) {
@@ -235,6 +238,7 @@ ErrCode marshalArray(
{
OSL_ASSERT(variable != 0);
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
@@ -410,8 +414,9 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
align(
reinterpret_cast< sal_uIntPtr >(data),
alignment(variable)));
- SbxArray * props = dynamic_cast<SbxObject*>( variable->GetObject() )->
- GetProperties();
+ SbxObject* pobj = dynamic_cast<SbxObject*>(variable->GetObject());
+ assert(pobj);
+ SbxArray* props = pobj->GetProperties();
for (sal_uInt16 i = 0; i < props->Count(); ++i) {
data = unmarshal(props->Get(i), data);
}
@@ -429,6 +434,7 @@ void const * unmarshal(SbxVariable * variable, void const * data) {
}
} else {
SbxDimArray * arr = dynamic_cast<SbxDimArray*>( variable->GetObject() );
+ assert(arr);
int dims = arr->GetDims();
std::vector< sal_Int32 > low(dims);
std::vector< sal_Int32 > up(dims);
diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx
index a648aff121ca..11a616a34f8e 100644
--- a/chart2/source/controller/dialogs/DialogModel.cxx
+++ b/chart2/source/controller/dialogs/DialogModel.cxx
@@ -854,6 +854,7 @@ ChartModel& DialogModel::getModel() const
{
uno::Reference< frame::XModel > xModel = getChartModel();
ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get());
+ assert(pModel);
return *pModel;
}
diff --git a/sfx2/source/inet/inettbc.cxx b/sfx2/source/inet/inettbc.cxx
index a8f42dbc3154..64bc24956e17 100644
--- a/sfx2/source/inet/inettbc.cxx
+++ b/sfx2/source/inet/inettbc.cxx
@@ -229,6 +229,7 @@ void SfxURLToolBoxControl_Impl::StateChanged
}
const SfxStringItem *pURL = dynamic_cast< const SfxStringItem* >(pState);
+ assert(pURL);
INetURLObject aURL( pURL->GetValue() );
INetProtocol eProt = aURL.GetProtocol();
if ( eProt == INetProtocol::File )
diff --git a/svx/source/form/filtnav.cxx b/svx/source/form/filtnav.cxx
index a05e6a56b9f9..5bcd6a4b8df3 100644
--- a/svx/source/form/filtnav.cxx
+++ b/svx/source/form/filtnav.cxx
@@ -294,7 +294,7 @@ void FmFilterAdapter::setText(sal_Int32 nRowPos,
const OUString& rText)
{
FmFormItem* pFormItem = dynamic_cast<FmFormItem*>( pFilterItem->GetParent()->GetParent() );
-
+ assert(pFormItem);
try
{
Reference< XFilterController > xController( pFormItem->GetController(), UNO_QUERY_THROW );
@@ -788,6 +788,7 @@ void FmFilterModel::Remove( const ::std::vector<std::unique_ptr<FmFilterData>>::
bool FmFilterModel::ValidateText(FmFilterItem const * pItem, OUString& rText, OUString& rErrorMsg) const
{
FmFormItem* pFormItem = dynamic_cast<FmFormItem*>( pItem->GetParent()->GetParent() );
+ assert(pFormItem);
try
{
Reference< XFormController > xFormController( pFormItem->GetController() );
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 9e061ebf754d..ee82f15ff86b 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -1484,6 +1484,7 @@ void CalcContent( SwLayoutFrame *pLay, bool bNoColl )
{
// #i28701#
SwAnchoredObject* pAnchoredObj = (*pFrame->GetDrawObjs())[i];
+ assert(pAnchoredObj);
// determine if anchored object has to be
// formatted and, in case, format it
diff --git a/sw/source/core/undo/docundo.cxx b/sw/source/core/undo/docundo.cxx
index 73105e2f5a02..06cf409f0731 100644
--- a/sw/source/core/undo/docundo.cxx
+++ b/sw/source/core/undo/docundo.cxx
@@ -673,15 +673,13 @@ bool UndoManager::Repeat(::sw::RepeatContext & rContext,
OUString const comment(pRepeatAction->GetComment());
OUString const rcomment(pRepeatAction->GetRepeatComment(rContext));
- auto const*const pListAction(dynamic_cast<SfxListUndoAction *>(pRepeatAction));
- auto const*const pSwAction(dynamic_cast<SwUndo *>(pRepeatAction));
- if (!pListAction && !pSwAction)
- {
+ SwUndoId nId;
+ if (auto const* const pSwAction = dynamic_cast<SwUndo*>(pRepeatAction))
+ nId = pSwAction->GetId();
+ else if (auto const* const pListAction = dynamic_cast<SfxListUndoAction*>(pRepeatAction))
+ nId = static_cast<SwUndoId>(pListAction->GetId());
+ else
return false;
- }
- SwUndoId const nId(pSwAction
- ? pSwAction->GetId()
- : static_cast<SwUndoId>(pListAction->GetId()));
if (DoesUndo())
{
ViewShellId nViewShellId(-1);
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index e4ce85632f08..f1c56fa5b686 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4174,8 +4174,7 @@ void DocxAttributeOutput::TableRowRedline( ww8::WW8TableNodeInfoInner::Pointer_t
{
SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
const SwTableRowRedline* pTableRowRedline = dynamic_cast<const SwTableRowRedline*>(pExtraRedline);
- const SwTableLine *pRedTabLine = pTableRowRedline ? &pTableRowRedline->GetTableLine() : nullptr;
- if (pRedTabLine == pTabLine)
+ if (pTableRowRedline && &pTableRowRedline->GetTableLine() == pTabLine)
{
// Redline for this table row
const SwRedlineData& aRedlineData = pTableRowRedline->GetRedlineData();
@@ -4220,8 +4219,7 @@ void DocxAttributeOutput::TableCellRedline( ww8::WW8TableNodeInfoInner::Pointer_
{
SwExtraRedline* pExtraRedline = aExtraRedlineTable.GetRedline(nCurRedlinePos);
const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
- const SwTableBox *pRedTabBox = pTableCellRedline ? &pTableCellRedline->GetTableBox() : nullptr;
- if (pRedTabBox == pTabBox)
+ if (pTableCellRedline && &pTableCellRedline->GetTableBox() == pTabBox)
{
// Redline for this table cell
const SwRedlineData& aRedlineData = pTableCellRedline->GetRedlineData();