Fixes of some memory leaks
This commit is contained in:
@@ -2619,8 +2619,10 @@ void HOGDescriptor::readALTModel(std::string modelfile)
|
||||
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)
|
||||
if(nread != static_cast<size_t>(length) + 1) {
|
||||
delete [] linearwt;
|
||||
throw Exception();
|
||||
}
|
||||
|
||||
for(int i = 0; i < length; i++)
|
||||
detector.push_back((float)linearwt[i]);
|
||||
|
||||
@@ -142,6 +142,7 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image,
|
||||
free(points);
|
||||
free(oppPoints);
|
||||
free(score);
|
||||
free(scoreOut);
|
||||
|
||||
return result_seq;
|
||||
}
|
||||
|
||||
@@ -741,8 +741,11 @@ int LSVMparser(const char * filename, CvLSVMFilterObject *** model, int *last, i
|
||||
//printf("parse : %s\n", filename);
|
||||
|
||||
xmlf = fopen(filename, "rb");
|
||||
if(xmlf == NULL)
|
||||
if(xmlf == NULL) {
|
||||
free(*model);
|
||||
*model = NULL;
|
||||
return LSVM_PARSER_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
//i = 0;
|
||||
j = 0;
|
||||
@@ -808,6 +811,7 @@ int loadModel(
|
||||
(*kPartFilters)[i] = (comp[i] - comp[i - 1]) - 1;
|
||||
}
|
||||
(*kPartFilters)[0] = comp[0];
|
||||
free(comp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user