Ignore:
Timestamp:
2012-08-30T12:45:08+12:00 (12 years ago)
Author:
kjdon
Message:

FindWordNumbers was doing a test to see if the appropriate stem index was built. eg if you ask for a casefolded search but there was no casefolded index built, then you can't do it, so set the stemMethod to 0, which means no stem/casefolding/accentfolding. Unfortunately, if the stemMethod was 0, then it was looking up an array at 0-1, which is some huge number (stem method is mg_u_long). For some reason, this didn't cause a seg fault on 32 bit machines, but did on 64 bit machines which is where the bug showed up. So we must test for stem method being 0 before looking into the stem file array

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/common-src/indexers/mgpp/text/Terms.cpp

    r25147 r26137  
    213213  // if the stem method specified is not a valid one (i.e. there was no appropriate stem index, then we set it to 0)
    214214  // unless we have partial matching, in which case we are not doing stem indexes anyway.
    215   if (!(stemMethod & STEM_PARTIAL_MATCH) && indexData.stemFile[stemMethod-1] == NULL) {
    216     cerr << "Stem index for method "<<stemMethod<< " was not built, so not doing stemming\n";
    217     stemMethod = 0;
     215
     216  if (!(stemMethod & STEM_PARTIAL_MATCH)) {
     217
     218    if(stemMethod > STEM_MAX) {
     219      cerr << "Stem method "<<stemMethod<< " is greater than maximum allowed ("<<STEM_MAX<<"). Not doing stemming\n";
     220      stemMethod=0;
     221    }
     222    else if (stemMethod > 0 && indexData.stemFile[stemMethod-1] == NULL) {
     223      cerr << "Stem index for method "<<stemMethod<< " was not built, so not doing stemming\n";
     224      stemMethod = 0;
     225    }
    218226  }
    219227  /* [JFG - Mar 06: Accent folding patch] */
     
    247255  mg_u_long stemmerNum = 0;
    248256
    249   /* [JFG - Mar 06: Accent folding patch] */
    250   if(stemMethod > STEM_MAX) {
    251     return;
    252     //TODO: throw an error here
    253   }
    254257
    255258  stemmerNum = indexData.sih[stemMethod-1].stemmer_num;
Note: See TracChangeset for help on using the changeset viewer.