mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Fixed some issues found by static analysis (4th round)
This commit is contained in:
@@ -610,7 +610,8 @@ cv::DetectionBasedTracker::DetectionBasedTracker(cv::Ptr<IDetector> mainDetector
|
||||
&& trackingDetector );
|
||||
|
||||
if (mainDetector) {
|
||||
separateDetectionWork.reset(new SeparateDetectionWork(*this, mainDetector, params));
|
||||
Ptr<SeparateDetectionWork> tmp(new SeparateDetectionWork(*this, mainDetector, params));
|
||||
separateDetectionWork.swap(tmp);
|
||||
}
|
||||
|
||||
weightsPositionsSmoothing.push_back(1);
|
||||
|
||||
@@ -1848,7 +1848,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
|
||||
sscanf( stage, "%d%n", &count, &dl );
|
||||
stage += dl;
|
||||
|
||||
assert( count > 0 );
|
||||
CV_Assert( count > 0 && count < CV_HAAR_STAGE_MAX);
|
||||
cascade->stage_classifier[i].count = count;
|
||||
cascade->stage_classifier[i].classifier =
|
||||
(CvHaarClassifier*)cvAlloc( count*sizeof(cascade->stage_classifier[i].classifier[0]));
|
||||
@@ -1862,6 +1862,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
|
||||
sscanf( stage, "%d%n", &classifier->count, &dl );
|
||||
stage += dl;
|
||||
|
||||
CV_Assert( classifier->count > 0 && classifier->count< CV_HAAR_STAGE_MAX);
|
||||
classifier->haar_feature = (CvHaarFeature*) cvAlloc(
|
||||
classifier->count * ( sizeof( *classifier->haar_feature ) +
|
||||
sizeof( *classifier->threshold ) +
|
||||
@@ -1878,7 +1879,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
|
||||
sscanf( stage, "%d%n", &rects, &dl );
|
||||
stage += dl;
|
||||
|
||||
assert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
|
||||
CV_DbgAssert( rects >= 2 && rects <= CV_HAAR_FEATURE_MAX );
|
||||
|
||||
for( k = 0; k < rects; k++ )
|
||||
{
|
||||
@@ -1890,7 +1891,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
|
||||
stage += dl;
|
||||
classifier->haar_feature[l].rect[k].r = r;
|
||||
}
|
||||
sscanf( stage, "%s%n", str, &dl );
|
||||
sscanf( stage, "%99s%n", str, &dl );
|
||||
stage += dl;
|
||||
|
||||
classifier->haar_feature[l].tilted = strncmp( str, "tilted", 6 ) == 0;
|
||||
@@ -1926,6 +1927,7 @@ icvLoadCascadeCART( const char** input_cascade, int n, CvSize orig_window_size )
|
||||
}
|
||||
stage += dl;
|
||||
|
||||
CV_Assert(parent >= 0 && parent < i);
|
||||
cascade->stage_classifier[i].parent = parent;
|
||||
cascade->stage_classifier[i].next = next;
|
||||
cascade->stage_classifier[i].child = -1;
|
||||
|
||||
@@ -3694,23 +3694,31 @@ void HOGDescriptor::readALTModel(String modelfile)
|
||||
String eerr("version?");
|
||||
String efile(__FILE__);
|
||||
String efunc(__FUNCTION__);
|
||||
fclose(modelfl);
|
||||
|
||||
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
|
||||
}
|
||||
if(strcmp(version_buffer,"V6.01")) {
|
||||
String eerr("version doesnot match");
|
||||
String efile(__FILE__);
|
||||
String efunc(__FUNCTION__);
|
||||
fclose(modelfl);
|
||||
|
||||
throw Exception(Error::StsError, eerr, efile, efunc, __LINE__);
|
||||
}
|
||||
/* read version number */
|
||||
int version = 0;
|
||||
if (!fread (&version,sizeof(int),1,modelfl))
|
||||
{ throw Exception(); }
|
||||
{
|
||||
fclose(modelfl);
|
||||
throw Exception();
|
||||
}
|
||||
if (version < 200)
|
||||
{
|
||||
String eerr("version doesnot match");
|
||||
String efile(__FILE__);
|
||||
String efunc(__FUNCTION__);
|
||||
fclose(modelfl);
|
||||
throw Exception();
|
||||
}
|
||||
int kernel_type;
|
||||
@@ -3729,6 +3737,7 @@ void HOGDescriptor::readALTModel(String modelfile)
|
||||
nread=fread(&(coef_const),sizeof(double),1,modelfl);
|
||||
int l;
|
||||
nread=fread(&l,sizeof(int),1,modelfl);
|
||||
CV_Assert(l >= 0 && l < 0xFFFF);
|
||||
char* custom = new char[l];
|
||||
nread=fread(custom,sizeof(char),l,modelfl);
|
||||
delete[] custom;
|
||||
@@ -3749,11 +3758,13 @@ void HOGDescriptor::readALTModel(String modelfile)
|
||||
detector.clear();
|
||||
if(kernel_type == 0) { /* linear kernel */
|
||||
/* save linear wts also */
|
||||
CV_Assert(totwords + 1 > 0 && totwords < 0xFFFF);
|
||||
double *linearwt = new double[totwords+1];
|
||||
int length = totwords;
|
||||
nread = fread(linearwt, sizeof(double), totwords + 1, modelfl);
|
||||
if(nread != static_cast<size_t>(length) + 1) {
|
||||
delete [] linearwt;
|
||||
fclose(modelfl);
|
||||
throw Exception();
|
||||
}
|
||||
|
||||
@@ -3764,6 +3775,7 @@ void HOGDescriptor::readALTModel(String modelfile)
|
||||
setSVMDetector(detector);
|
||||
delete [] linearwt;
|
||||
} else {
|
||||
fclose(modelfl);
|
||||
throw Exception();
|
||||
}
|
||||
fclose(modelfl);
|
||||
|
||||
Reference in New Issue
Block a user