diff --git a/modules/contrib/src/chamfermatching.cpp b/modules/contrib/src/chamfermatching.cpp index 17d06b3b75..64d77cf0d5 100644 --- a/modules/contrib/src/chamfermatching.cpp +++ b/modules/contrib/src/chamfermatching.cpp @@ -476,12 +476,19 @@ public: chamfer_ = new Matching(true); } + ~ChamferMatcher() + { + delete chamfer_; + } + void showMatch(Mat& img, int index = 0); void showMatch(Mat& img, Match match_); const Matches& matching(Template&, Mat&); private: + ChamferMatcher(const ChamferMatcher&); + ChamferMatcher& operator=(const ChamferMatcher&); void addMatch(float cost, Point offset, const Template* tpl); diff --git a/modules/contrib/src/fuzzymeanshifttracker.cpp b/modules/contrib/src/fuzzymeanshifttracker.cpp index d221d49c0f..0ac6d24437 100644 --- a/modules/contrib/src/fuzzymeanshifttracker.cpp +++ b/modules/contrib/src/fuzzymeanshifttracker.cpp @@ -79,9 +79,7 @@ void CvFuzzyCurve::clear() void CvFuzzyCurve::addPoint(double x, double y) { - CvFuzzyPoint *point; - point = new CvFuzzyPoint(x, y); - points.push_back(*point); + points.push_back(CvFuzzyPoint(x, y)); }; double CvFuzzyCurve::calcValue(double param) diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index 14b2190564..8f2c7728c5 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -209,6 +209,7 @@ int CvMLData::read_csv(const char* filename) if (!token) { fclose(file); + delete [] el_ptr; return -1; } } diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 7287d57ecc..41744f6d5f 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -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(length) + 1) + if(nread != static_cast(length) + 1) { + delete [] linearwt; throw Exception(); + } for(int i = 0; i < length; i++) detector.push_back((float)linearwt[i]); diff --git a/modules/objdetect/src/latentsvmdetector.cpp b/modules/objdetect/src/latentsvmdetector.cpp index 743b93ee14..3a24983200 100644 --- a/modules/objdetect/src/latentsvmdetector.cpp +++ b/modules/objdetect/src/latentsvmdetector.cpp @@ -142,6 +142,7 @@ CvSeq* cvLatentSvmDetectObjects(IplImage* image, free(points); free(oppPoints); free(score); + free(scoreOut); return result_seq; } diff --git a/modules/objdetect/src/lsvmparser.cpp b/modules/objdetect/src/lsvmparser.cpp index 585d963577..52c4d825d1 100644 --- a/modules/objdetect/src/lsvmparser.cpp +++ b/modules/objdetect/src/lsvmparser.cpp @@ -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; @@ -787,7 +790,7 @@ int loadModel( float *scoreThreshold){ int last; int max; - int *comp; + int *comp = NULL; int count; int i; int err; @@ -808,6 +811,7 @@ int loadModel( (*kPartFilters)[i] = (comp[i] - comp[i - 1]) - 1; } (*kPartFilters)[0] = comp[0]; + free(comp); return 0; }