fix issue 1018, 1031

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@918 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
zdenop 2013-12-06 22:07:46 +00:00
parent bf0a83907b
commit 38b25b5777
10 changed files with 15 additions and 4 deletions

View File

@ -26,7 +26,6 @@
class BlamerBundle; class BlamerBundle;
class C_BLOB_IT; class C_BLOB_IT;
class PBLOB_IT;
class PAGE_RES; class PAGE_RES;
class PAGE_RES_IT; class PAGE_RES_IT;
class WERD; class WERD;

View File

@ -26,7 +26,6 @@
class BLOCK; class BLOCK;
class DENORM; class DENORM;
class PBLOB_LIST;
struct TWERD; struct TWERD;
class UNICHARSET; class UNICHARSET;
class WERD; class WERD;

View File

@ -97,7 +97,6 @@ void OtsuThreshold(const unsigned char* imagedata,
} }
} }
} }
delete[] histogramAllChannels;
#else #else
for (int ch = 0; ch < bytes_per_pixel; ++ch) { for (int ch = 0; ch < bytes_per_pixel; ++ch) {
@ -136,6 +135,7 @@ void OtsuThreshold(const unsigned char* imagedata,
} }
} }
#endif // USE_OPENCL #endif // USE_OPENCL
delete[] histogramAllChannels;
if (!any_good_hivalue) { if (!any_good_hivalue) {
// Use the best of the ones that were not good enough. // Use the best of the ones that were not good enough.

View File

@ -1689,7 +1689,10 @@ UNICHAR_ID *Classify::GetAmbiguities(TBLOB *Blob,
TrainingSample* sample = TrainingSample* sample =
BlobToTrainingSample(*Blob, classify_nonlinear_norm, &fx_info, BlobToTrainingSample(*Blob, classify_nonlinear_norm, &fx_info,
&bl_features); &bl_features);
if (sample == NULL) return NULL; if (sample == NULL) {
delete Results;
return NULL;
}
CharNormClassifier(Blob, *sample, Results); CharNormClassifier(Blob, *sample, Results);
delete sample; delete sample;

View File

@ -415,6 +415,7 @@ bool MasterTrainer::LoadXHeights(const char* filename) {
if (xheights_[i] < 0) if (xheights_[i] < 0)
xheights_[i] = mean_xheight; xheights_[i] = mean_xheight;
} }
fclose(f);
return true; return true;
} // LoadXHeights } // LoadXHeights

View File

@ -100,14 +100,17 @@ CharSampSet * CharSampSet::FromCharDumpFile(string file_name) {
} }
// read and verify marker // read and verify marker
if (fread(&val32, 1, sizeof(val32), fp) != sizeof(val32)) { if (fread(&val32, 1, sizeof(val32), fp) != sizeof(val32)) {
fclose(fp);
return NULL; return NULL;
} }
if (val32 != 0xfefeabd0) { if (val32 != 0xfefeabd0) {
fclose(fp);
return NULL; return NULL;
} }
// create an object // create an object
CharSampSet *samp_set = new CharSampSet(); CharSampSet *samp_set = new CharSampSet();
if (samp_set == NULL) { if (samp_set == NULL) {
fclose(fp);
return NULL; return NULL;
} }
if (samp_set->LoadCharSamples(fp) == false) { if (samp_set->LoadCharSamples(fp) == false) {

View File

@ -210,6 +210,7 @@ ConComp **ConComp::Segment(int max_hist_wnd, int *concomp_cnt) {
// no segments, nothing to do // no segments, nothing to do
if (seg_pt_cnt == 0) { if (seg_pt_cnt == 0) {
delete []x_seg_pt;
return NULL; return NULL;
} }

View File

@ -689,6 +689,7 @@ bool CubeLineSegmenter::LineSegment() {
// get the pix and box corresponding to the column // get the pix and box corresponding to the column
Pix *pixt3 = pixaGetPix(pixad, col, L_CLONE); Pix *pixt3 = pixaGetPix(pixad, col, L_CLONE);
if (pixt3 == NULL) { if (pixt3 == NULL) {
delete []col_order;
return false; return false;
} }
@ -697,6 +698,7 @@ bool CubeLineSegmenter::LineSegment() {
Pixa *pixac; Pixa *pixac;
Boxa *boxa2 = pixConnComp(pixt3, &pixac, 8); Boxa *boxa2 = pixConnComp(pixt3, &pixac, 8);
if (boxa2 == NULL) { if (boxa2 == NULL) {
delete []col_order;
return false; return false;
} }
@ -709,6 +711,7 @@ bool CubeLineSegmenter::LineSegment() {
// add the lines // add the lines
if (AddLines(pixac) == true) { if (AddLines(pixac) == true) {
if (pixaaAddBox(columns_, col_box, L_CLONE) != 0) { if (pixaaAddBox(columns_, col_box, L_CLONE) != 0) {
delete []col_order;
return false; return false;
} }
} }

View File

@ -328,6 +328,7 @@ static ds_status readProFile(const char* fileName, char** content, size_t* conte
rewind(input); rewind(input);
binary = (char*)malloc(size); binary = (char*)malloc(size);
if(binary == NULL) { if(binary == NULL) {
fclose(input);
return DS_FILE_ERROR; return DS_FILE_ERROR;
} }
fread(binary, sizeof(char), size, input); fread(binary, sizeof(char), size, input);

View File

@ -601,6 +601,7 @@ bool LanguageModel::AddViterbiStateEntry(
tprintf("Language model components very early pruned this entry\n"); tprintf("Language model components very early pruned this entry\n");
} }
delete ngram_info; delete ngram_info;
delete dawg_info;
return false; return false;
} }