Ignore:
Timestamp:
2011-01-25T18:15:15+13:00 (13 years ago)
Author:
ak19
Message:

Fixed a bug that cased library.cgi to crash (apache and server.exe): the now-corrected order of the tests in the while condition matter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/querytools.cpp

    r22984 r23635  
    407407      query_no_brackets += substr(here, bracket);
    408408      // skip the :TI bits
    409       while (*bracket != ' ' && bracket != end) { bracket++;}
     409      while (bracket != end     // do bracket != end test first, ELSE when bracket = end, we're past the string, in
     410          && *bracket != ' ') { // which case *bracket becomes an invalid operation that causes the server to crash
     411            bracket++;
     412      }
    410413      here = bracket;
    411414    }
     
    418421      // back up the field name
    419422      text_t::const_iterator old_bracket = bracket;
    420       while (*bracket != ' ' && bracket != here) {
    421     --bracket;
     423      while (bracket != here && *bracket != ' ') {  // order of tests in condition matters (see long comment above)
     424    --bracket;                     
    422425      }
    423426      if (bracket != here) {
Note: See TracChangeset for help on using the changeset viewer.