Skip to content

Commit 638a01a

Browse files
committed
Merge pull request opencv#9038 from mshabunin:fix-static-4
2 parents 90d2f8b + e0393f8 commit 638a01a

29 files changed

+168
-46
lines changed

modules/calib3d/src/ap3p.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ap3p {
3333
double fx, fy, cx, cy;
3434
double inv_fx, inv_fy, cx_fx, cy_fy;
3535
public:
36-
ap3p() {}
36+
ap3p() : fx(0), fy(0), cx(0), cy(0), inv_fx(0), inv_fy(0), cx_fx(0), cy_fy(0) {}
3737

3838
ap3p(double fx, double fy, double cx, double cy);
3939

modules/calib3d/src/epnp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,8 @@ void epnp::qr_solve(CvMat * A, CvMat * b, CvMat * X)
525525
{
526526
const int nr = A->rows;
527527
const int nc = A->cols;
528+
if (nc <= 0 || nr <= 0)
529+
return;
528530

529531
if (max_nr != 0 && max_nr < nr)
530532
{

modules/calib3d/src/upnp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ void upnp::qr_solve(Mat * A, Mat * b, Mat * X)
720720
{
721721
const int nr = A->rows;
722722
const int nc = A->cols;
723+
if (nr <= 0 || nc <= 0)
724+
return;
723725

724726
if (max_nr != 0 && max_nr < nr)
725727
{

modules/core/include/opencv2/core/cvstd.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
#endif
5050

5151
#include "opencv2/core/cvdef.h"
52-
5352
#include <cstddef>
5453
#include <cstring>
5554
#include <cctype>
@@ -959,8 +958,9 @@ size_t String::find_last_of(const char* s, size_t pos) const
959958
inline
960959
String String::toLowerCase() const
961960
{
961+
if (!cstr_)
962+
return String();
962963
String res(cstr_, len_);
963-
964964
for (size_t i = 0; i < len_; ++i)
965965
res.cstr_[i] = (char) ::tolower(cstr_[i]);
966966

modules/core/src/matrix.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5699,13 +5699,20 @@ double norm( const SparseMat& src, int normType )
56995699
{
57005700
if( normType == NORM_INF )
57015701
for( i = 0; i < N; i++, ++it )
5702+
{
5703+
CV_Assert(it.ptr);
57025704
result = std::max(result, std::abs((double)it.value<float>()));
5705+
}
57035706
else if( normType == NORM_L1 )
57045707
for( i = 0; i < N; i++, ++it )
5708+
{
5709+
CV_Assert(it.ptr);
57055710
result += std::abs(it.value<float>());
5711+
}
57065712
else
57075713
for( i = 0; i < N; i++, ++it )
57085714
{
5715+
CV_Assert(it.ptr);
57095716
double v = it.value<float>();
57105717
result += v*v;
57115718
}
@@ -5714,13 +5721,20 @@ double norm( const SparseMat& src, int normType )
57145721
{
57155722
if( normType == NORM_INF )
57165723
for( i = 0; i < N; i++, ++it )
5724+
{
5725+
CV_Assert(it.ptr);
57175726
result = std::max(result, std::abs(it.value<double>()));
5727+
}
57185728
else if( normType == NORM_L1 )
57195729
for( i = 0; i < N; i++, ++it )
5730+
{
5731+
CV_Assert(it.ptr);
57205732
result += std::abs(it.value<double>());
5733+
}
57215734
else
57225735
for( i = 0; i < N; i++, ++it )
57235736
{
5737+
CV_Assert(it.ptr);
57245738
double v = it.value<double>();
57255739
result += v*v;
57265740
}
@@ -5747,6 +5761,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi
57475761
float minval = FLT_MAX, maxval = -FLT_MAX;
57485762
for( i = 0; i < N; i++, ++it )
57495763
{
5764+
CV_Assert(it.ptr);
57505765
float v = it.value<float>();
57515766
if( v < minval )
57525767
{
@@ -5769,6 +5784,7 @@ void minMaxLoc( const SparseMat& src, double* _minval, double* _maxval, int* _mi
57695784
double minval = DBL_MAX, maxval = -DBL_MAX;
57705785
for( i = 0; i < N; i++, ++it )
57715786
{
5787+
CV_Assert(it.ptr);
57725788
double v = it.value<double>();
57735789
if( v < minval )
57745790
{

modules/dnn/src/layers/convolution_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class ConvolutionLayerImpl : public BaseConvolutionLayerImpl
289289

290290
ParallelConv()
291291
: input_(0), weights_(0), output_(0), ngroups_(0), nstripes_(0),
292-
is1x1_(false), useAVX2(false)
292+
biasvec_(0), reluslope_(0), activ_(0), is1x1_(false), useAVX2(false)
293293
{}
294294

295295
static void run( const Mat& input, Mat& output, const Mat& weights,

modules/dnn/src/layers/eltwise_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class EltwiseLayerImpl : public EltwiseLayer
120120
int nstripes;
121121
const ActivationLayer* activ;
122122

123-
EltwiseInvoker() {}
123+
EltwiseInvoker() : srcs(0), nsrcs(0), dst(0), coeffs(0), op(EltwiseLayer::PROD), nstripes(0), activ(0) {}
124124

125125
static void run(const Mat** srcs, int nsrcs, Mat& dst,
126126
const std::vector<int>& coeffs, EltwiseOp op,

modules/dnn/src/layers/fully_connected_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class FullyConnectedLayerImpl : public InnerProductLayer
119119
class FullyConnected : public ParallelLoopBody
120120
{
121121
public:
122-
FullyConnected() {}
122+
FullyConnected() : srcMat(0), weights(0), biasMat(0), activ(0), dstMat(0), nstripes(0), useAVX2(false) {}
123123

124124
static void run(const Mat& srcMat, const Mat& weights, const Mat& biasMat,
125125
Mat& dstMat, const ActivationLayer* activ, int nstripes)

modules/dnn/src/layers/permute_layer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class PermuteLayerImpl : public PermuteLayer
195195
parallel_for_(Range(0, nstripes), p, nstripes);
196196
}
197197

198-
PermuteInvoker() {}
198+
PermuteInvoker() : inp(0), out(0), order(0), nstripes(0) {}
199199

200200
void operator()(const Range& r) const
201201
{

modules/dnn/src/layers/pooling_layer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class PoolingLayerImpl : public PoolingLayer
147147
std::vector<int> ofsbuf;
148148
int poolingType;
149149

150-
PoolingInvoker() {}
150+
PoolingInvoker() : src(0), dst(0), mask(0), nstripes(0), computeMaxIdx(0), poolingType(PoolingLayer::MAX) {}
151151

152152
static void run(const Mat& src, Mat& dst, Mat& mask, Size kernel,
153153
Size stride, Size pad, int poolingType,
@@ -263,8 +263,11 @@ class PoolingLayerImpl : public PoolingLayer
263263
}
264264
v_store(dstData + x0, max_val0);
265265
v_store(dstData + x0 + 4, max_val1);
266-
v_store(dstMaskData + x0, max_idx0);
267-
v_store(dstMaskData + x0 + 4, max_idx1);
266+
if (dstMaskData)
267+
{
268+
v_store(dstMaskData + x0, max_idx0);
269+
v_store(dstMaskData + x0 + 4, max_idx1);
270+
}
268271
x0 += 7;
269272
}
270273
else
@@ -350,7 +353,8 @@ class PoolingLayerImpl : public PoolingLayer
350353
}
351354

352355
dstData[x0] = max_val;
353-
dstMaskData[x0] = max_index;
356+
if (dstMaskData)
357+
dstMaskData[x0] = max_index;
354358
}
355359
else
356360
{

0 commit comments

Comments
 (0)