1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

Merge pull request #12391 from DEEPIR:master

fix some errors found by static analyzer. (#12391)

* fix possible divided by zero and by negative values

* only 4 elements are used in these arrays

* fix uninitialized member

* use boolean type for semantic boolean variables

* avoid invalid array index

* to avoid exception and because base64_beg is only used in this block

* use std::atomic<bool> to avoid thread control race condition
This commit is contained in:
cyy
2018-09-04 21:39:19 +08:00
committed by Alexander Alekhin
parent f826709452
commit 10fb88d027
9 changed files with 12 additions and 13 deletions
+2 -2
View File
@@ -939,7 +939,7 @@ bool _InputArray::isContinuous(int i) const
if( k == STD_VECTOR_MAT )
{
const std::vector<Mat>& vv = *(const std::vector<Mat>*)obj;
CV_Assert((size_t)i < vv.size());
CV_Assert(i >= 0 && (size_t)i < vv.size());
return vv[i].isContinuous();
}
@@ -953,7 +953,7 @@ bool _InputArray::isContinuous(int i) const
if( k == STD_VECTOR_UMAT )
{
const std::vector<UMat>& vv = *(const std::vector<UMat>*)obj;
CV_Assert((size_t)i < vv.size());
CV_Assert(i >= 0 && (size_t)i < vv.size());
return vv[i].isContinuous();
}
+1 -1
View File
@@ -337,7 +337,7 @@ public:
std::atomic<int> completed_thread_count; // number of threads completed any activities on this job
int64 dummy2_[8]; // avoid cache-line reusing for the same atomics
volatile bool is_completed; // std::atomic_flag ?
std::atomic<bool> is_completed;
// TODO exception handling
};
+2 -2
View File
@@ -238,11 +238,11 @@ static char* icvJSONParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node )
CV_PARSE_ERROR("Invalid `dt` in Base64 header");
}
/* set base64_beg to beginning of base64 data */
base64_beg = &base64_buffer.at( base64::ENCODED_HEADER_SIZE );
if ( base64_buffer.size() > base64::ENCODED_HEADER_SIZE )
{
/* set base64_beg to beginning of base64 data */
base64_beg = &base64_buffer.at( base64::ENCODED_HEADER_SIZE );
if ( !base64::base64_valid( base64_beg, 0U, base64_end - base64_beg ) )
CV_PARSE_ERROR( "Invalid Base64 data." );