Program: 152460
Project: 152460
Buggy source:
private void appendSearchIndexJoin(StringBuilder sb,Uri uri,String[] projection,String filter){
  sb.append("String_Node_Str" + SearchIndexColumns.CONTACT_ID + "String_Node_Str");
  boolean snippetNeeded=mDbHelper.isInProjection(projection,SearchSnippetColumns.SNIPPET);
  boolean isEmailAddress=false;
  String emailAddress=null;
  boolean isPhoneNumber=false;
  String phoneNumber=null;
  if (snippetNeeded) {
    if (filter.indexOf('@') != -1) {
      emailAddress=mDbHelper.extractAddressFromEmailAddress(filter);
      isEmailAddress=!TextUtils.isEmpty(emailAddress);
    }
 else {
      isPhoneNumber=isPhoneNumber(filter);
    }
    String[] args=null;
    String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
    if (snippetArgs != null) {
      args=snippetArgs.split("String_Node_Str");
    }
    String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
    String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
    String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
    int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
    sb.append("String_Node_Str");
    if (isEmailAddress) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,startMatch);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,endMatch);
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
 else     if (isPhoneNumber) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,startMatch);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,endMatch);
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
 else {
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str" + SearchSnippetColumns.SNIPPET);
  }
  sb.append("String_Node_Str" + Tables.SEARCH_INDEX);
  if (isEmailAddress) {
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Email.ADDRESS+ "String_Node_Str"+ "String_Node_Str"+ Tables.DATA_JOIN_RAW_CONTACTS+ "String_Node_Str"+ Email.ADDRESS+ "String_Node_Str");
    DatabaseUtils.appendEscapedSQLString(sb,filter + "String_Node_Str");
    sb.append("String_Node_Str");
  }
 else   if (isPhoneNumber) {
    phoneNumber=PhoneNumberUtils.normalizeNumber(filter);
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Phone.NUMBER+ "String_Node_Str"+ "String_Node_Str"+ Tables.DATA_JOIN_RAW_CONTACTS+ "String_Node_Str"+ Tables.PHONE_LOOKUP+ "String_Node_Str"+ DataColumns.CONCRETE_ID+ "String_Node_Str"+ Tables.PHONE_LOOKUP+ "String_Node_Str"+ PhoneLookupColumns.DATA_ID+ "String_Node_Str"+ "String_Node_Str"+ PhoneLookupColumns.NORMALIZED_NUMBER+ "String_Node_Str");
    sb.append(phoneNumber);
    sb.append("String_Node_Str");
    String numberE164=PhoneNumberUtils.formatNumberToE164(phoneNumber,mDbHelper.getCountryIso());
    if (!TextUtils.isEmpty(numberE164)) {
      sb.append("String_Node_Str" + PhoneLookupColumns.NORMALIZED_NUMBER + "String_Node_Str");
      sb.append(numberE164);
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Tables.NAME_LOOKUP+ "String_Node_Str"+ RawContactsColumns.CONCRETE_ID+ "String_Node_Str"+ NameLookupColumns.RAW_CONTACT_ID+ "String_Node_Str");
    String normalizedFilter=NameNormalizer.normalize(filter);
    if (!TextUtils.isEmpty(normalizedFilter)) {
      sb.append("String_Node_Str");
      sb.append(normalizedFilter);
      sb.append("String_Node_Str" + NameLookupColumns.NAME_TYPE + "String_Node_Str"+ NameLookupType.NAME_COLLATION_KEY);
    }
 else {
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append(Tables.SEARCH_INDEX + "String_Node_Str");
  if (isEmailAddress) {
    DatabaseUtils.appendEscapedSQLString(sb,"String_Node_Str" + filter + "String_Node_Str");
  }
 else   if (isPhoneNumber) {
    DatabaseUtils.appendEscapedSQLString(sb,"String_Node_Str" + filter + "String_Node_Str"+ phoneNumber+ "String_Node_Str");
  }
 else {
    DatabaseUtils.appendEscapedSQLString(sb,filter + "String_Node_Str");
  }
  sb.append("String_Node_Str" + Contacts._ID + "String_Node_Str");
}

Fixed version (ground truth):
private void appendSearchIndexJoin(StringBuilder sb,Uri uri,String[] projection,String filter){
  sb.append("String_Node_Str" + SearchIndexColumns.CONTACT_ID + "String_Node_Str");
  boolean snippetNeeded=mDbHelper.isInProjection(projection,SearchSnippetColumns.SNIPPET);
  boolean isEmailAddress=false;
  String emailAddress=null;
  boolean isPhoneNumber=false;
  String phoneNumber=null;
  String numberE164=null;
  if (filter.indexOf('@') != -1) {
    emailAddress=mDbHelper.extractAddressFromEmailAddress(filter);
    isEmailAddress=!TextUtils.isEmpty(emailAddress);
  }
 else {
    isPhoneNumber=isPhoneNumber(filter);
  }
  if (snippetNeeded) {
    String[] args=null;
    String snippetArgs=getQueryParameter(uri,SearchSnippetColumns.SNIPPET_ARGS_PARAM_KEY);
    if (snippetArgs != null) {
      args=snippetArgs.split("String_Node_Str");
    }
    String startMatch=args != null && args.length > 0 ? args[0] : DEFAULT_SNIPPET_ARG_START_MATCH;
    String endMatch=args != null && args.length > 1 ? args[1] : DEFAULT_SNIPPET_ARG_END_MATCH;
    String ellipsis=args != null && args.length > 2 ? args[2] : DEFAULT_SNIPPET_ARG_ELLIPSIS;
    int maxTokens=args != null && args.length > 3 ? Integer.parseInt(args[3]) : DEFAULT_SNIPPET_ARG_MAX_TOKENS;
    sb.append("String_Node_Str");
    if (isEmailAddress) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,startMatch);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,endMatch);
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
 else     if (isPhoneNumber) {
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,startMatch);
      sb.append("String_Node_Str");
      DatabaseUtils.appendEscapedSQLString(sb,endMatch);
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
 else {
      sb.append("String_Node_Str");
      appendSnippetFunction(sb,startMatch,endMatch,ellipsis,maxTokens);
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str" + SearchSnippetColumns.SNIPPET);
  }
  sb.append("String_Node_Str" + Tables.SEARCH_INDEX);
  if (isEmailAddress) {
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Email.ADDRESS+ "String_Node_Str"+ "String_Node_Str"+ Tables.DATA_JOIN_RAW_CONTACTS+ "String_Node_Str"+ Email.ADDRESS+ "String_Node_Str");
    DatabaseUtils.appendEscapedSQLString(sb,filter + "String_Node_Str");
    sb.append("String_Node_Str");
  }
 else   if (isPhoneNumber) {
    phoneNumber=PhoneNumberUtils.normalizeNumber(filter);
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Phone.NUMBER+ "String_Node_Str"+ "String_Node_Str"+ Tables.DATA_JOIN_RAW_CONTACTS+ "String_Node_Str"+ Tables.PHONE_LOOKUP+ "String_Node_Str"+ DataColumns.CONCRETE_ID+ "String_Node_Str"+ Tables.PHONE_LOOKUP+ "String_Node_Str"+ PhoneLookupColumns.DATA_ID+ "String_Node_Str"+ "String_Node_Str"+ PhoneLookupColumns.NORMALIZED_NUMBER+ "String_Node_Str");
    sb.append(phoneNumber);
    sb.append("String_Node_Str");
    numberE164=PhoneNumberUtils.formatNumberToE164(phoneNumber,mDbHelper.getCountryIso());
    if (!TextUtils.isEmpty(numberE164)) {
      sb.append("String_Node_Str" + PhoneLookupColumns.NORMALIZED_NUMBER + "String_Node_Str");
      sb.append(numberE164);
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str");
    sb.append("String_Node_Str");
  }
 else {
    sb.append("String_Node_Str" + "String_Node_Str" + RawContacts.CONTACT_ID + "String_Node_Str"+ "String_Node_Str"+ Tables.RAW_CONTACTS+ "String_Node_Str"+ Tables.NAME_LOOKUP+ "String_Node_Str"+ RawContactsColumns.CONCRETE_ID+ "String_Node_Str"+ NameLookupColumns.RAW_CONTACT_ID+ "String_Node_Str");
    String normalizedFilter=NameNormalizer.normalize(filter);
    if (!TextUtils.isEmpty(normalizedFilter)) {
      sb.append("String_Node_Str");
      sb.append(normalizedFilter);
      sb.append("String_Node_Str" + NameLookupColumns.NAME_TYPE + "String_Node_Str"+ NameLookupType.NAME_COLLATION_KEY);
    }
 else {
      sb.append("String_Node_Str");
    }
    sb.append("String_Node_Str");
  }
  sb.append("String_Node_Str");
  sb.append(Tables.SEARCH_INDEX + "String_Node_Str");
  if (isEmailAddress) {
    DatabaseUtils.appendEscapedSQLString(sb,"String_Node_Str" + filter + "String_Node_Str");
  }
 else   if (isPhoneNumber) {
    DatabaseUtils.appendEscapedSQLString(sb,"String_Node_Str" + filter + "String_Node_Str"+ phoneNumber+ "String_Node_Str"+ (numberE164 != null ? "String_Node_Str" + numberE164 + "String_Node_Str" : "String_Node_Str"));
  }
 else {
    DatabaseUtils.appendEscapedSQLString(sb,filter + "String_Node_Str");
  }
  sb.append("String_Node_Str" + Contacts._ID + "String_Node_Str");
}