Skip to content

Commit e6d9486

Browse files
committed
Fixed several issues found by static analysis
1 parent 9a8e47a commit e6d9486

File tree

7 files changed

+11
-5
lines changed

7 files changed

+11
-5
lines changed

modules/calib3d/src/calibration.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,7 @@ CV_IMPL void cvFindExtrinsicCameraParams2( const CvMat* objectPoints,
11331133
if( cvDet(&_RR) < 0 )
11341134
cvScale( &_RRt, &_RRt, -1 );
11351135
sc = cvNorm(&_RR);
1136+
CV_Assert(fabs(sc) > DBL_EPSILON);
11361137
cvSVD( &_RR, &matW, &matU, &matV, CV_SVD_MODIFY_A + CV_SVD_U_T + CV_SVD_V_T );
11371138
cvGEMM( &matU, &matV, 1, 0, 0, &matR, CV_GEMM_A_T );
11381139
cvScale( &_tt, &_t, cvNorm(&matR)/sc );

modules/calib3d/src/chessboard.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ cv::Mat findHomography1D(cv::InputArray _src,cv::InputArray _dst)
164164
Mat H = dst_T.inv()*Mat(H_, false)*src_T;
165165

166166
// enforce frobeniusnorm of one
167-
double scale = 1.0/cv::norm(H);
167+
double scale = cv::norm(H);
168+
CV_Assert(fabs(scale) > DBL_EPSILON);
169+
scale = 1.0 / scale;
168170
return H*scale;
169171
}
170172
void polyfit(const Mat& src_x, const Mat& src_y, Mat& dst, int order)

modules/core/include/opencv2/core/cvdef.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ class float16_t
654654
public:
655655
#if CV_FP16_TYPE
656656

657-
float16_t() {}
657+
float16_t() : h(0) {}
658658
explicit float16_t(float x) { h = (__fp16)x; }
659659
operator float() const { return (float)h; }
660660
static float16_t fromBits(ushort w)
@@ -681,7 +681,7 @@ class float16_t
681681
__fp16 h;
682682

683683
#else
684-
float16_t() {}
684+
float16_t() : w(0) {}
685685
explicit float16_t(float x)
686686
{
687687
#if CV_AVX2

modules/dnn/src/layers/pooling_layer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,8 @@ class PoolingLayerImpl CV_FINAL : public PoolingLayer
332332
int poolingType;
333333
float spatialScale;
334334

335-
PoolingInvoker() : src(0), rois(0), dst(0), mask(0), avePoolPaddedArea(false), nstripes(0),
335+
PoolingInvoker() : src(0), rois(0), dst(0), mask(0), pad_l(0), pad_t(0), pad_r(0), pad_b(0),
336+
avePoolPaddedArea(false), nstripes(0),
336337
computeMaxIdx(0), poolingType(MAX), spatialScale(0) {}
337338

338339
static void run(const Mat& src, const Mat& rois, Mat& dst, Mat& mask, Size kernel,

modules/imgcodecs/src/grfmt_pfm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ PFMDecoder::~PFMDecoder()
7979
{
8080
}
8181

82-
PFMDecoder::PFMDecoder()
82+
PFMDecoder::PFMDecoder() : m_scale_factor(0), m_swap_byte_order(false)
8383
{
8484
m_strm.close();
8585
}

modules/imgproc/src/contours.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,7 @@ icvFindContoursInInterval( const CvArr* src,
15321532
tmp_prev->link = 0;
15331533

15341534
// First line. None of runs is binded
1535+
tmp.pt.x = 0;
15351536
tmp.pt.y = 0;
15361537
CV_WRITE_SEQ_ELEM( tmp, writer );
15371538
upper_line = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer );

modules/objdetect/src/hog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ void HOGDescriptor::computeGradient(InputArray _img, InputOutputArray _grad, Inp
240240
CV_INSTRUMENT_REGION();
241241

242242
Mat img = _img.getMat();
243+
CV_Assert(!img.empty());
243244
CV_Assert( img.type() == CV_8U || img.type() == CV_8UC3 );
244245

245246
Size gradsize(img.cols + paddingTL.width + paddingBR.width,

0 commit comments

Comments
 (0)