Program: 12225
Project: 12225
Buggy source:
/** 
 * Opens the SQLite database and performs all initialization required for the current mode The readonly param should only be used in experimentation where you don't want to alter previous database state. <p>semantic_memory.cpp:1952:smem_init_db
 * @param readonly
 * @throws SoarException
 * @throws SQLException
 * @throws IOException
 */
void smem_init_db(boolean readonly) throws SoarException, SQLException, IOException {
  if (db != null) {
    return;
  }
  final String db_path;
  if (true) {
    db_path="String_Node_Str";
  }
 else {
    db_path="String_Node_Str";
  }
  final Connection connection=JdbcTools.connect("String_Node_Str","String_Node_Str" + db_path);
  try {
    db=new SemanticMemoryDatabase(connection);
  }
 catch (  SoarException e) {
    connection.close();
    throw e;
  }
{
{
      final int cacheSize=5000;
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str" + cacheSize);
    }
    if (false) {
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
    }
  }
  smem_validation++;
  db.structure();
  db.prepare();
  smem_reset_id_counters();
  db.begin.executeUpdate();
  if (!readonly) {
    final ByRef<Long> tempMaxCycle=ByRef.create(smem_max_cycle);
    if (!smem_variable_get(smem_variable_key.var_max_cycle,tempMaxCycle)) {
      smem_max_cycle=1;
    }
 else {
      smem_max_cycle=tempMaxCycle.value;
    }
{
      ByRef<Long> temp=ByRef.create(0L);
      if (smem_variable_get(smem_variable_key.var_act_thresh,temp)) {
      }
 else {
        smem_variable_set(smem_variable_key.var_act_thresh,0L);
      }
      if (smem_variable_get(smem_variable_key.var_num_nodes,temp)) {
      }
 else {
      }
      if (smem_variable_get(smem_variable_key.var_num_edges,temp)) {
      }
 else {
      }
    }
  }
  db.commit.executeUpdate();
  if (false) {
    db.begin.executeUpdate();
  }
}

Fixed version (ground truth):
/** 
 * Opens the SQLite database and performs all initialization required for the current mode The readonly param should only be used in experimentation where you don't want to alter previous database state. <p>semantic_memory.cpp:1952:smem_init_db
 * @param readonly
 * @throws SoarException
 * @throws SQLException
 * @throws IOException
 */
void smem_init_db(boolean readonly) throws SoarException, SQLException, IOException {
  if (db != null) {
    return;
  }
  final String db_path;
  if (true) {
    db_path="String_Node_Str";
  }
 else {
    db_path="String_Node_Str";
  }
  final Connection connection=JdbcTools.connect("String_Node_Str","String_Node_Str" + db_path);
  try {
    db=new SemanticMemoryDatabase(connection);
  }
 catch (  SoarException e) {
    connection.close();
    throw e;
  }
{
{
      final int cacheSize=5000;
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str" + cacheSize);
    }
    if (false) {
      final Statement s=db.getConnection().createStatement();
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
      s.execute("String_Node_Str");
    }
  }
  smem_validation++;
  db.structure();
  db.prepare();
  smem_reset_id_counters();
  db.begin.executeUpdate();
  if (!readonly) {
    final ByRef<Long> tempMaxCycle=ByRef.create(smem_max_cycle);
    if (!smem_variable_get(smem_variable_key.var_max_cycle,tempMaxCycle)) {
      smem_max_cycle=1;
    }
 else {
      smem_max_cycle=tempMaxCycle.value;
    }
{
      ByRef<Long> temp=ByRef.create(0L);
      if (smem_variable_get(smem_variable_key.var_act_thresh,temp)) {
      }
 else {
        smem_variable_set(smem_variable_key.var_act_thresh,100L);
      }
      if (smem_variable_get(smem_variable_key.var_num_nodes,temp)) {
      }
 else {
      }
      if (smem_variable_get(smem_variable_key.var_num_edges,temp)) {
      }
 else {
      }
    }
  }
  db.commit.executeUpdate();
  if (false) {
    db.begin.executeUpdate();
  }
}