diff --git a/ccmain/pageiterator.h b/ccmain/pageiterator.h index d3dfc78fb0..b8d1701e96 100644 --- a/ccmain/pageiterator.h +++ b/ccmain/pageiterator.h @@ -26,7 +26,6 @@ class BlamerBundle; class C_BLOB_IT; -class PBLOB_IT; class PAGE_RES; class PAGE_RES_IT; class WERD; diff --git a/ccstruct/boxword.h b/ccstruct/boxword.h index 6dc1719a4f..c8495b59aa 100644 --- a/ccstruct/boxword.h +++ b/ccstruct/boxword.h @@ -26,7 +26,6 @@ class BLOCK; class DENORM; -class PBLOB_LIST; struct TWERD; class UNICHARSET; class WERD; diff --git a/ccstruct/otsuthr.cpp b/ccstruct/otsuthr.cpp index 47128be186..3f23d5a821 100644 --- a/ccstruct/otsuthr.cpp +++ b/ccstruct/otsuthr.cpp @@ -97,7 +97,6 @@ void OtsuThreshold(const unsigned char* imagedata, } } } - delete[] histogramAllChannels; #else for (int ch = 0; ch < bytes_per_pixel; ++ch) { @@ -136,6 +135,7 @@ void OtsuThreshold(const unsigned char* imagedata, } } #endif // USE_OPENCL + delete[] histogramAllChannels; if (!any_good_hivalue) { // Use the best of the ones that were not good enough. diff --git a/classify/adaptmatch.cpp b/classify/adaptmatch.cpp index 6051a95a02..816b92c400 100644 --- a/classify/adaptmatch.cpp +++ b/classify/adaptmatch.cpp @@ -1689,7 +1689,10 @@ UNICHAR_ID *Classify::GetAmbiguities(TBLOB *Blob, TrainingSample* sample = BlobToTrainingSample(*Blob, classify_nonlinear_norm, &fx_info, &bl_features); - if (sample == NULL) return NULL; + if (sample == NULL) { + delete Results; + return NULL; + } CharNormClassifier(Blob, *sample, Results); delete sample; diff --git a/classify/mastertrainer.cpp b/classify/mastertrainer.cpp index 1e69da14b2..7726814fac 100644 --- a/classify/mastertrainer.cpp +++ b/classify/mastertrainer.cpp @@ -415,6 +415,7 @@ bool MasterTrainer::LoadXHeights(const char* filename) { if (xheights_[i] < 0) xheights_[i] = mean_xheight; } + fclose(f); return true; } // LoadXHeights diff --git a/cube/char_samp_set.cpp b/cube/char_samp_set.cpp index de99b37438..65caa397a1 100644 --- a/cube/char_samp_set.cpp +++ b/cube/char_samp_set.cpp @@ -100,14 +100,17 @@ CharSampSet * CharSampSet::FromCharDumpFile(string file_name) { } // read and verify marker if (fread(&val32, 1, sizeof(val32), fp) != sizeof(val32)) { + fclose(fp); return NULL; } if (val32 != 0xfefeabd0) { + fclose(fp); return NULL; } // create an object CharSampSet *samp_set = new CharSampSet(); if (samp_set == NULL) { + fclose(fp); return NULL; } if (samp_set->LoadCharSamples(fp) == false) { diff --git a/cube/con_comp.cpp b/cube/con_comp.cpp index f043253ad4..53b1a73b43 100644 --- a/cube/con_comp.cpp +++ b/cube/con_comp.cpp @@ -210,6 +210,7 @@ ConComp **ConComp::Segment(int max_hist_wnd, int *concomp_cnt) { // no segments, nothing to do if (seg_pt_cnt == 0) { + delete []x_seg_pt; return NULL; } diff --git a/cube/cube_line_segmenter.cpp b/cube/cube_line_segmenter.cpp index 3f0b762a3f..916992c577 100644 --- a/cube/cube_line_segmenter.cpp +++ b/cube/cube_line_segmenter.cpp @@ -689,6 +689,7 @@ bool CubeLineSegmenter::LineSegment() { // get the pix and box corresponding to the column Pix *pixt3 = pixaGetPix(pixad, col, L_CLONE); if (pixt3 == NULL) { + delete []col_order; return false; } @@ -697,6 +698,7 @@ bool CubeLineSegmenter::LineSegment() { Pixa *pixac; Boxa *boxa2 = pixConnComp(pixt3, &pixac, 8); if (boxa2 == NULL) { + delete []col_order; return false; } @@ -709,6 +711,7 @@ bool CubeLineSegmenter::LineSegment() { // add the lines if (AddLines(pixac) == true) { if (pixaaAddBox(columns_, col_box, L_CLONE) != 0) { + delete []col_order; return false; } } diff --git a/opencl/opencl_device_selection.h b/opencl/opencl_device_selection.h index 0ce3adbead..d28f2a278e 100644 --- a/opencl/opencl_device_selection.h +++ b/opencl/opencl_device_selection.h @@ -328,6 +328,7 @@ static ds_status readProFile(const char* fileName, char** content, size_t* conte rewind(input); binary = (char*)malloc(size); if(binary == NULL) { + fclose(input); return DS_FILE_ERROR; } fread(binary, sizeof(char), size, input); diff --git a/wordrec/language_model.cpp b/wordrec/language_model.cpp index b4cdffa127..487e2e94b0 100644 --- a/wordrec/language_model.cpp +++ b/wordrec/language_model.cpp @@ -601,6 +601,7 @@ bool LanguageModel::AddViterbiStateEntry( tprintf("Language model components very early pruned this entry\n"); } delete ngram_info; + delete dawg_info; return false; }