Commit 06f6f74e authored by Roman Donchenko's avatar Roman Donchenko Committed by OpenCV Buildbot

Merge pull request #1839 from pmiecielica:memory_leaks

parents 59aa516c a19cc6cb
...@@ -476,12 +476,19 @@ public: ...@@ -476,12 +476,19 @@ public:
chamfer_ = new Matching(true); chamfer_ = new Matching(true);
} }
~ChamferMatcher()
{
delete chamfer_;
}
void showMatch(Mat& img, int index = 0); void showMatch(Mat& img, int index = 0);
void showMatch(Mat& img, Match match_); void showMatch(Mat& img, Match match_);
const Matches& matching(Template&, Mat&); const Matches& matching(Template&, Mat&);
private: private:
ChamferMatcher(const ChamferMatcher&);
ChamferMatcher& operator=(const ChamferMatcher&);
void addMatch(float cost, Point offset, const Template* tpl); void addMatch(float cost, Point offset, const Template* tpl);
......
...@@ -79,9 +79,7 @@ void CvFuzzyCurve::clear() ...@@ -79,9 +79,7 @@ void CvFuzzyCurve::clear()
void CvFuzzyCurve::addPoint(double x, double y) void CvFuzzyCurve::addPoint(double x, double y)
{ {
CvFuzzyPoint *point; points.push_back(CvFuzzyPoint(x, y));
point = new CvFuzzyPoint(x, y);
points.push_back(*point);
}; };
double CvFuzzyCurve::calcValue(double param) double CvFuzzyCurve::calcValue(double param)
......
...@@ -209,6 +209,7 @@ int CvMLData::read_csv(const char* filename) ...@@ -209,6 +209,7 @@ int CvMLData::read_csv(const char* filename)
if (!token) if (!token)
{ {
fclose(file); fclose(file);
delete [] el_ptr;
return -1; return -1;
} }
} }
......
...@@ -2619,8 +2619,10 @@ void HOGDescriptor::readALTModel(std::string modelfile) ...@@ -2619,8 +2619,10 @@ void HOGDescriptor::readALTModel(std::string modelfile)
double *linearwt = new double[totwords+1]; double *linearwt = new double[totwords+1];
int length = totwords; int length = totwords;
nread = fread(linearwt, sizeof(double), totwords + 1, modelfl); 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(); throw Exception();
}
for(int i = 0; i < length; i++) for(int i = 0; i < length; i++)
detector.push_back((float)linearwt[i]); detector.push_back((float)linearwt[i]);
......
...@@ -142,6 +142,7 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image, ...@@ -142,6 +142,7 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image,
free(points); free(points);
free(oppPoints); free(oppPoints);
free(score); free(score);
free(scoreOut);
return result_seq; return result_seq;
} }
......
...@@ -741,8 +741,11 @@ int LSVMparser(const char * filename, CvLSVMFilterObject *** model, int *last, i ...@@ -741,8 +741,11 @@ int LSVMparser(const char * filename, CvLSVMFilterObject *** model, int *last, i
//printf("parse : %s\n", filename); //printf("parse : %s\n", filename);
xmlf = fopen(filename, "rb"); xmlf = fopen(filename, "rb");
if(xmlf == NULL) if(xmlf == NULL) {
free(*model);
*model = NULL;
return LSVM_PARSER_FILE_NOT_FOUND; return LSVM_PARSER_FILE_NOT_FOUND;
}
//i = 0; //i = 0;
j = 0; j = 0;
...@@ -787,7 +790,7 @@ int loadModel( ...@@ -787,7 +790,7 @@ int loadModel(
float *scoreThreshold){ float *scoreThreshold){
int last; int last;
int max; int max;
int *comp; int *comp = NULL;
int count; int count;
int i; int i;
int err; int err;
...@@ -808,6 +811,7 @@ int loadModel( ...@@ -808,6 +811,7 @@ int loadModel(
(*kPartFilters)[i] = (comp[i] - comp[i - 1]) - 1; (*kPartFilters)[i] = (comp[i] - comp[i - 1]) - 1;
} }
(*kPartFilters)[0] = comp[0]; (*kPartFilters)[0] = comp[0];
free(comp);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment