Fixed several issues found by static analysis

This commit is contained in:
Maksim Shabunin
2017-06-28 16:26:55 +03:00
parent bbb14d3746
commit a769d69a9d
35 changed files with 113 additions and 66 deletions
+1 -1
View File
@@ -276,10 +276,10 @@ CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parse
{
if( this != &parser )
{
CV_XADD(&parser.impl->refcount, 1);
if(CV_XADD(&impl->refcount, -1) == 1)
delete impl;
impl = parser.impl;
CV_XADD(&impl->refcount, 1);
}
return *this;
}
+2 -1
View File
@@ -283,8 +283,9 @@ void Mat::copyTo( OutputArray _dst ) const
}
_dst.create( dims, size.p, type() );
UMat dst = _dst.getUMat();
CV_Assert(dst.u != NULL);
size_t i, sz[CV_MAX_DIM] = {0}, dstofs[CV_MAX_DIM], esz = elemSize();
CV_Assert(dims >= 0 && dims < CV_MAX_DIM);
for( i = 0; i < (size_t)dims; i++ )
sz[i] = size.p[i];
sz[dims-1] *= esz;
+1
View File
@@ -2547,6 +2547,7 @@ cvSetAdd( CvSet* set, CvSetElem* element, CvSetElem** inserted_element )
CV_IMPL void
cvSetRemove( CvSet* set, int index )
{
CV_Assert(set != NULL);
CvSetElem* elem = cvGetSetElem( set, index );
if( elem )
cvSetRemoveByPtr( set, elem );
+1 -1
View File
@@ -1129,7 +1129,7 @@ Mat Mat::diag(const Mat& d)
int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) const
{
return (depth() == _depth || _depth <= 0) &&
return data && (depth() == _depth || _depth <= 0) &&
(isContinuous() || !_requireContinuous) &&
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
(cols == _elemChannels && channels() == 1))) ||
+2 -1
View File
@@ -804,7 +804,7 @@ cvGetFileNode( CvFileStorage* fs, CvFileNode* _map_node,
if( !map_node )
map_node = (CvFileNode*)cvGetSeqElem( fs->roots, k );
CV_Assert(map_node != NULL);
if( !CV_NODE_IS_MAP(map_node->tag) )
{
if( (!CV_NODE_IS_SEQ(map_node->tag) || map_node->data.seq->total != 0) &&
@@ -6777,6 +6777,7 @@ cvLoad( const char* filename, CvMemStorage* memstorage,
CvSeqReader reader;
node = (CvFileNode*)cvGetSeqElem( (*fs)->roots, k );
CV_Assert(node != NULL);
if( !CV_NODE_IS_MAP( node->tag ))
return 0;
seq = node->data.seq;
+7 -4
View File
@@ -1193,10 +1193,13 @@ Mutex::Mutex(const Mutex& m)
Mutex& Mutex::operator = (const Mutex& m)
{
CV_XADD(&m.impl->refcount, 1);
if( CV_XADD(&impl->refcount, -1) == 1 )
delete impl;
impl = m.impl;
if (this != &m)
{
CV_XADD(&m.impl->refcount, 1);
if( CV_XADD(&impl->refcount, -1) == 1 )
delete impl;
impl = m.impl;
}
return *this;
}
+9
View File
@@ -225,6 +225,11 @@ Region::LocationExtraData::LocationExtraData(const LocationStaticStorage& locati
ittHandle_name = __itt_string_handle_create(location.name);
ittHandle_filename = __itt_string_handle_create(location.filename);
}
else
{
ittHandle_name = 0;
ittHandle_filename = 0;
}
#endif
}
@@ -1019,6 +1024,10 @@ struct TraceArg::ExtraData
// Consecutive calls to __itt_string_handle_create with the same name return the same value.
ittHandle_name = __itt_string_handle_create(arg.name);
}
else
{
ittHandle_name = 0;
}
#endif
}
};