Program: 12131
Project: 12131
Buggy source:
/** 
 * <p> semantic_memory.cpp:2145:_smem_process_cue_wme
 * @param state
 * @param query
 * @param prohibit
 * @param query_level
 * @return
 * @throws SQLException
 */
boolean _smem_process_cue_wme(WmeImpl w,boolean pos_cue,PriorityQueue<WeightedCueElement> weighted_pq) throws SQLException {
  boolean good_wme=true;
  WeightedCueElement new_cue_element;
  long attr_hash;
  long value_hash;
  long value_lti;
  smem_cue_element_type element_type=null;
  PreparedStatement q=null;
{
    attr_hash=smem_temporal_hash(w.attr,false);
    if (attr_hash != 0) {
      if (w.value.symbol_is_constant()) {
        value_lti=0;
        value_hash=smem_temporal_hash(w.value,false);
        if (value_hash != 0) {
          q=db.wmes_constant_frequency_get;
          q.setLong(1,attr_hash);
          q.setLong(2,value_hash);
          element_type=smem_cue_element_type.value_const_t;
        }
 else {
          if (pos_cue) {
            good_wme=false;
          }
        }
      }
 else {
        value_lti=w.value.asIdentifier().smem_lti;
        value_hash=0;
        if (value_lti == 0) {
          q=db.attribute_frequency_get;
          q.setLong(1,attr_hash);
          element_type=smem_cue_element_type.attr_t;
        }
 else {
          q=db.wmes_lti_frequency_get;
          q.setLong(1,attr_hash);
          q.setLong(2,value_lti);
          element_type=smem_cue_element_type.value_lti_t;
        }
      }
      if (good_wme) {
        ResultSet rs=q.executeQuery();
        try {
          if (rs.next()) {
            new_cue_element=new WeightedCueElement();
            new_cue_element.weight=rs.getLong(0 + 1);
            new_cue_element.attr_hash=attr_hash;
            new_cue_element.value_hash=value_hash;
            new_cue_element.value_lti=value_lti;
            new_cue_element.cue_element=w;
            new_cue_element.element_type=element_type;
            new_cue_element.pos_element=pos_cue;
            weighted_pq.add(new_cue_element);
            new_cue_element=null;
          }
 else {
            if (pos_cue) {
              good_wme=false;
            }
          }
        }
  finally {
          rs.close();
        }
      }
    }
 else {
      if (pos_cue) {
        good_wme=false;
      }
    }
  }
  return good_wme;
}

Fixed version (ground truth):
/** 
 * <p> semantic_memory.cpp:2145:_smem_process_cue_wme
 * @param state
 * @param query
 * @param prohibit
 * @param query_level
 * @return
 * @throws SQLException
 */
boolean _smem_process_cue_wme(WmeImpl w,boolean pos_cue,PriorityQueue<WeightedCueElement> weighted_pq) throws SQLException {
  boolean good_wme=true;
  WeightedCueElement new_cue_element;
  long attr_hash;
  long value_hash;
  long value_lti;
  smem_cue_element_type element_type=null;
  PreparedStatement q=null;
{
    attr_hash=smem_temporal_hash(w.attr,false);
    if (attr_hash != 0) {
      if (w.value.symbol_is_constant()) {
        value_lti=0;
        value_hash=smem_temporal_hash(w.value,false);
        element_type=smem_cue_element_type.value_const_t;
        if (value_hash != 0) {
          q=db.wmes_constant_frequency_get;
          q.setLong(1,attr_hash);
          q.setLong(2,value_hash);
        }
 else         if (pos_cue) {
          good_wme=false;
        }
      }
 else {
        value_lti=w.value.asIdentifier().smem_lti;
        value_hash=0;
        if (value_lti == 0) {
          q=db.attribute_frequency_get;
          q.setLong(1,attr_hash);
          element_type=smem_cue_element_type.attr_t;
        }
 else {
          q=db.wmes_lti_frequency_get;
          q.setLong(1,attr_hash);
          q.setLong(2,value_lti);
          element_type=smem_cue_element_type.value_lti_t;
        }
      }
      if (good_wme) {
        ResultSet rs=q.executeQuery();
        try {
          if (rs.next()) {
            new_cue_element=new WeightedCueElement();
            new_cue_element.weight=rs.getLong(0 + 1);
            new_cue_element.attr_hash=attr_hash;
            new_cue_element.value_hash=value_hash;
            new_cue_element.value_lti=value_lti;
            new_cue_element.cue_element=w;
            new_cue_element.element_type=element_type;
            new_cue_element.pos_element=pos_cue;
            weighted_pq.add(new_cue_element);
            new_cue_element=null;
          }
 else {
            if (pos_cue) {
              good_wme=false;
            }
          }
        }
  finally {
          rs.close();
        }
      }
    }
 else {
      if (pos_cue) {
        good_wme=false;
      }
    }
  }
  return good_wme;
}