Program: 16207
Project: 16207
Buggy source:
private void initialize(String sql) throws SQLException {
  if (sql == null) {
    sql="String_Node_Str";
  }
  originalSQL=sql;
  sqlCommand=sql;
  int len=sql.length() + 1;
  char[] command=new char[len];
  int[] types=new int[len];
  len--;
  sql.getChars(0,len,command,0);
  boolean changed=false;
  command[len]=' ';
  int startLoop=0;
  for (int i=0; i < len; i++) {
    char c=command[i];
    int type=0;
switch (c) {
case '/':
      if (command[i + 1] == '*') {
        changed=true;
        command[i]=' ';
        command[i + 1]=' ';
        startLoop=i;
        i+=2;
        checkRunOver(i,len,startLoop);
        while (command[i] != '*' || command[i + 1] != '/') {
          command[i++]=' ';
          checkRunOver(i,len,startLoop);
        }
        command[i]=' ';
        command[i + 1]=' ';
        i++;
      }
 else       if (command[i + 1] == '/') {
        changed=true;
        startLoop=i;
        while (true) {
          c=command[i];
          if (c == '\n' || c == '\r' || i >= len - 1) {
            break;
          }
          command[i++]=' ';
          checkRunOver(i,len,startLoop);
        }
      }
 else {
        type=CHAR_SPECIAL_1;
      }
    break;
case '-':
  if (command[i + 1] == '-') {
    changed=true;
    startLoop=i;
    while (true) {
      c=command[i];
      if (c == '\n' || c == '\r' || i >= len - 1) {
        break;
      }
      command[i++]=' ';
      checkRunOver(i,len,startLoop);
    }
  }
 else {
    type=CHAR_SPECIAL_1;
  }
break;
case '$':
if (SysProperties.DOLLAR_QUOTING && command[i + 1] == '$' && (i == 0 || command[i - 1] <= ' ')) {
changed=true;
command[i]=' ';
command[i + 1]=' ';
startLoop=i;
i+=2;
checkRunOver(i,len,startLoop);
while (command[i] != '$' || command[i + 1] != '$') {
  types[i++]=CHAR_DOLLAR_QUOTED_STRING;
  checkRunOver(i,len,startLoop);
}
command[i]=' ';
command[i + 1]=' ';
i++;
}
 else {
type=CHAR_SPECIAL_1;
}
break;
case '(':
case ')':
case '{':
case '}':
case '*':
case ',':
case ';':
case '+':
case '%':
case '?':
case '@':
case ']':
type=CHAR_SPECIAL_1;
break;
case '!':
case '<':
case '>':
case '|':
case '=':
case ':':
case '~':
type=CHAR_SPECIAL_2;
break;
case '.':
type=CHAR_DECIMAL;
break;
case '\'':
type=types[i]=CHAR_STRING;
startLoop=i;
while (command[++i] != '\'') {
checkRunOver(i,len,startLoop);
}
break;
case '[':
if (database.getMode().squareBracketQuotedNames) {
command[i]='"';
changed=true;
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != ']') {
checkRunOver(i,len,startLoop);
}
command[i]='"';
}
 else {
type=CHAR_SPECIAL_1;
}
break;
case '`':
command[i]='"';
changed=true;
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != '`') {
checkRunOver(i,len,startLoop);
c=command[i];
command[i]=Character.toUpperCase(c);
}
command[i]='"';
break;
case '\"':
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != '\"') {
checkRunOver(i,len,startLoop);
}
break;
case '_':
type=CHAR_NAME;
break;
default :
if (c >= 'a' && c <= 'z') {
command[i]=(char)(c - ('a' - 'A'));
changed=true;
type=CHAR_NAME;
}
 else if (c >= 'A' && c <= 'Z') {
type=CHAR_NAME;
}
 else if (c >= '0' && c <= '9') {
type=CHAR_VALUE;
}
 else {
if (Character.isJavaIdentifierPart(c)) {
type=CHAR_NAME;
char u=Character.toUpperCase(c);
if (u != c) {
command[i]=u;
changed=true;
}
}
}
}
types[i]=(byte)type;
}
sqlCommandChars=command;
types[len]=CHAR_END;
characterTypes=types;
if (changed) {
sqlCommand=new String(command);
}
parseIndex=0;
}

Fixed version (ground truth):
private void initialize(String sql) throws SQLException {
  if (sql == null) {
    sql="String_Node_Str";
  }
  originalSQL=sql;
  sqlCommand=sql;
  int len=sql.length() + 1;
  char[] command=new char[len];
  int[] types=new int[len];
  len--;
  sql.getChars(0,len,command,0);
  boolean changed=false;
  command[len]=' ';
  int startLoop=0;
  for (int i=0; i < len; i++) {
    char c=command[i];
    int type=0;
switch (c) {
case '/':
      if (command[i + 1] == '*') {
        changed=true;
        command[i]=' ';
        command[i + 1]=' ';
        startLoop=i;
        i+=2;
        checkRunOver(i,len,startLoop);
        while (command[i] != '*' || command[i + 1] != '/') {
          command[i++]=' ';
          checkRunOver(i,len,startLoop);
        }
        command[i]=' ';
        command[i + 1]=' ';
        i++;
      }
 else       if (command[i + 1] == '/') {
        changed=true;
        startLoop=i;
        while (true) {
          c=command[i];
          if (c == '\n' || c == '\r' || i >= len - 1) {
            break;
          }
          command[i++]=' ';
          checkRunOver(i,len,startLoop);
        }
      }
 else {
        type=CHAR_SPECIAL_1;
      }
    break;
case '-':
  if (command[i + 1] == '-') {
    changed=true;
    startLoop=i;
    while (true) {
      c=command[i];
      if (c == '\n' || c == '\r' || i >= len - 1) {
        break;
      }
      command[i++]=' ';
      checkRunOver(i,len,startLoop);
    }
  }
 else {
    type=CHAR_SPECIAL_1;
  }
break;
case '$':
if (SysProperties.DOLLAR_QUOTING && command[i + 1] == '$' && (i == 0 || command[i - 1] <= ' ')) {
changed=true;
command[i]=' ';
command[i + 1]=' ';
startLoop=i;
i+=2;
checkRunOver(i,len,startLoop);
while (command[i] != '$' || command[i + 1] != '$') {
  types[i++]=CHAR_DOLLAR_QUOTED_STRING;
  checkRunOver(i,len,startLoop);
}
command[i]=' ';
command[i + 1]=' ';
i++;
}
 else {
type=CHAR_NAME;
}
break;
case '(':
case ')':
case '{':
case '}':
case '*':
case ',':
case ';':
case '+':
case '%':
case '?':
case '@':
case ']':
type=CHAR_SPECIAL_1;
break;
case '!':
case '<':
case '>':
case '|':
case '=':
case ':':
case '~':
type=CHAR_SPECIAL_2;
break;
case '.':
type=CHAR_DECIMAL;
break;
case '\'':
type=types[i]=CHAR_STRING;
startLoop=i;
while (command[++i] != '\'') {
checkRunOver(i,len,startLoop);
}
break;
case '[':
if (database.getMode().squareBracketQuotedNames) {
command[i]='"';
changed=true;
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != ']') {
checkRunOver(i,len,startLoop);
}
command[i]='"';
}
 else {
type=CHAR_SPECIAL_1;
}
break;
case '`':
command[i]='"';
changed=true;
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != '`') {
checkRunOver(i,len,startLoop);
c=command[i];
command[i]=Character.toUpperCase(c);
}
command[i]='"';
break;
case '\"':
type=types[i]=CHAR_QUOTED;
startLoop=i;
while (command[++i] != '\"') {
checkRunOver(i,len,startLoop);
}
break;
case '_':
type=CHAR_NAME;
break;
default :
if (c >= 'a' && c <= 'z') {
command[i]=(char)(c - ('a' - 'A'));
changed=true;
type=CHAR_NAME;
}
 else if (c >= 'A' && c <= 'Z') {
type=CHAR_NAME;
}
 else if (c >= '0' && c <= '9') {
type=CHAR_VALUE;
}
 else {
if (Character.isJavaIdentifierPart(c)) {
type=CHAR_NAME;
char u=Character.toUpperCase(c);
if (u != c) {
command[i]=u;
changed=true;
}
}
}
}
types[i]=(byte)type;
}
sqlCommandChars=command;
types[len]=CHAR_END;
characterTypes=types;
if (changed) {
sqlCommand=new String(command);
}
parseIndex=0;
}