Program: 185027
Project: 185027
Buggy source:
/** 
 * Save the data to the database.  Also, change the view to dialog stating  that the webpage has been saved.
 */
boolean save(){
  String title=mTitle.getText().toString().trim();
  String unfilteredUrl=BrowserActivity.fixUrl(mAddress.getText().toString());
  boolean emptyTitle=title.length() == 0;
  boolean emptyUrl=unfilteredUrl.trim().length() == 0;
  Resources r=getResources();
  if (emptyTitle || emptyUrl) {
    if (emptyTitle) {
      mTitle.setError(r.getText(R.string.bookmark_needs_title));
    }
    if (emptyUrl) {
      mAddress.setError(r.getText(R.string.bookmark_needs_url));
    }
    return false;
  }
  String url=unfilteredUrl;
  if (!(url.startsWith("String_Node_Str") || url.startsWith("String_Node_Str") || url.startsWith("String_Node_Str"))) {
    WebAddress address;
    try {
      address=new WebAddress(unfilteredUrl);
    }
 catch (    ParseException e) {
      mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
      return false;
    }
    if (address.mHost.length() == 0) {
      mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
      return false;
    }
    url=address.toString();
  }
  try {
    if (mEditingExisting) {
      mMap.putString("String_Node_Str",title);
      mMap.putString("String_Node_Str",url);
      setResult(RESULT_OK,(new Intent()).setAction(getIntent().toString()).putExtras(mMap));
    }
 else {
      long creationTime=new Date().getTime();
      boolean secure=false;
      if (url.startsWith("String_Node_Str")) {
        url=url.substring(7);
      }
 else       if (url.startsWith("String_Node_Str")) {
        url=url.substring(8);
        secure=true;
      }
      if (url.startsWith("String_Node_Str")) {
        url=url.substring(4);
      }
      if (secure) {
        SELECTION_ARGS=new String[2];
        SELECTION_ARGS[0]="String_Node_Str" + url;
        SELECTION_ARGS[1]="String_Node_Str" + url;
      }
 else {
        SELECTION_ARGS=new String[4];
        SELECTION_ARGS[0]=url;
        SELECTION_ARGS[1]="String_Node_Str" + url;
        SELECTION_ARGS[2]="String_Node_Str" + url;
        SELECTION_ARGS[3]="String_Node_Str" + SELECTION_ARGS[1];
      }
      ContentResolver cr=getContentResolver();
      Cursor c=cr.query(Browser.BOOKMARKS_URI,mProjection,secure ? WHERE_CLAUSE_SECURE : WHERE_CLAUSE,SELECTION_ARGS,null);
      ContentValues map=new ContentValues();
      if (c.moveToFirst() && c.getInt(c.getColumnIndexOrThrow(Browser.BookmarkColumns.BOOKMARK)) == 0) {
        map.put(Browser.BookmarkColumns.CREATED,creationTime);
        map.put(Browser.BookmarkColumns.TITLE,title);
        map.put(Browser.BookmarkColumns.BOOKMARK,1);
        cr.update(Browser.BOOKMARKS_URI,map,"String_Node_Str" + c.getInt(0),null);
      }
 else {
        int count=c.getCount();
        boolean matchedTitle=false;
        for (int i=0; i < count; i++) {
          c.moveToPosition(i);
          if (c.getString(c.getColumnIndexOrThrow(Browser.BookmarkColumns.TITLE)).equals(title)) {
            map.put(Browser.BookmarkColumns.CREATED,creationTime);
            cr.update(Browser.BOOKMARKS_URI,map,"String_Node_Str" + c.getInt(0),null);
            matchedTitle=true;
            break;
          }
        }
        if (!matchedTitle) {
          map.put(Browser.BookmarkColumns.TITLE,title);
          map.put(Browser.BookmarkColumns.URL,url);
          map.put(Browser.BookmarkColumns.CREATED,creationTime);
          map.put(Browser.BookmarkColumns.BOOKMARK,1);
          map.put(Browser.BookmarkColumns.DATE,0);
          int visits=0;
          if (count > 0) {
            visits=c.getInt(c.getColumnIndexOrThrow(Browser.BookmarkColumns.VISITS));
          }
          map.put(Browser.BookmarkColumns.VISITS,visits + 3);
          cr.insert(Browser.BOOKMARKS_URI,map);
        }
      }
      WebIconDatabase.getInstance().retainIconForPageUrl(url);
      c.deactivate();
      setResult(RESULT_OK);
    }
  }
 catch (  IllegalStateException e) {
    setTitle(r.getText(R.string.no_database));
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Save the data to the database.  Also, change the view to dialog stating  that the webpage has been saved.
 */
boolean save(){
  String title=mTitle.getText().toString().trim();
  String unfilteredUrl=BrowserActivity.fixUrl(mAddress.getText().toString());
  boolean emptyTitle=title.length() == 0;
  boolean emptyUrl=unfilteredUrl.trim().length() == 0;
  Resources r=getResources();
  if (emptyTitle || emptyUrl) {
    if (emptyTitle) {
      mTitle.setError(r.getText(R.string.bookmark_needs_title));
    }
    if (emptyUrl) {
      mAddress.setError(r.getText(R.string.bookmark_needs_url));
    }
    return false;
  }
  String url=unfilteredUrl;
  if (!(url.startsWith("String_Node_Str") || url.startsWith("String_Node_Str") || url.startsWith("String_Node_Str"))) {
    WebAddress address;
    try {
      address=new WebAddress(unfilteredUrl);
    }
 catch (    ParseException e) {
      mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
      return false;
    }
    if (address.mHost.length() == 0) {
      mAddress.setError(r.getText(R.string.bookmark_url_not_valid));
      return false;
    }
    url=address.toString();
  }
  try {
    if (mEditingExisting) {
      mMap.putString("String_Node_Str",title);
      mMap.putString("String_Node_Str",url);
      setResult(RESULT_OK,(new Intent()).setAction(getIntent().toString()).putExtras(mMap));
    }
 else {
      long creationTime=new Date().getTime();
      boolean secure=false;
      String compareString=url;
      if (compareString.startsWith("String_Node_Str")) {
        compareString=compareString.substring(7);
      }
 else       if (compareString.startsWith("String_Node_Str")) {
        compareString=compareString.substring(8);
        secure=true;
      }
      if (compareString.startsWith("String_Node_Str")) {
        compareString=compareString.substring(4);
      }
      if (secure) {
        SELECTION_ARGS=new String[2];
        SELECTION_ARGS[0]="String_Node_Str" + compareString;
        SELECTION_ARGS[1]="String_Node_Str" + compareString;
      }
 else {
        SELECTION_ARGS=new String[4];
        SELECTION_ARGS[0]=compareString;
        SELECTION_ARGS[1]="String_Node_Str" + compareString;
        SELECTION_ARGS[2]="String_Node_Str" + compareString;
        SELECTION_ARGS[3]="String_Node_Str" + SELECTION_ARGS[1];
      }
      ContentResolver cr=getContentResolver();
      Cursor c=cr.query(Browser.BOOKMARKS_URI,mProjection,secure ? WHERE_CLAUSE_SECURE : WHERE_CLAUSE,SELECTION_ARGS,null);
      ContentValues map=new ContentValues();
      if (c.moveToFirst() && c.getInt(c.getColumnIndexOrThrow(Browser.BookmarkColumns.BOOKMARK)) == 0) {
        map.put(Browser.BookmarkColumns.CREATED,creationTime);
        map.put(Browser.BookmarkColumns.TITLE,title);
        map.put(Browser.BookmarkColumns.BOOKMARK,1);
        cr.update(Browser.BOOKMARKS_URI,map,"String_Node_Str" + c.getInt(0),null);
      }
 else {
        int count=c.getCount();
        boolean matchedTitle=false;
        for (int i=0; i < count; i++) {
          c.moveToPosition(i);
          if (c.getString(c.getColumnIndexOrThrow(Browser.BookmarkColumns.TITLE)).equals(title)) {
            map.put(Browser.BookmarkColumns.CREATED,creationTime);
            cr.update(Browser.BOOKMARKS_URI,map,"String_Node_Str" + c.getInt(0),null);
            matchedTitle=true;
            break;
          }
        }
        if (!matchedTitle) {
          map.put(Browser.BookmarkColumns.TITLE,title);
          map.put(Browser.BookmarkColumns.URL,url);
          map.put(Browser.BookmarkColumns.CREATED,creationTime);
          map.put(Browser.BookmarkColumns.BOOKMARK,1);
          map.put(Browser.BookmarkColumns.DATE,0);
          int visits=0;
          if (count > 0) {
            visits=c.getInt(c.getColumnIndexOrThrow(Browser.BookmarkColumns.VISITS));
          }
          map.put(Browser.BookmarkColumns.VISITS,visits + 3);
          cr.insert(Browser.BOOKMARKS_URI,map);
        }
      }
      WebIconDatabase.getInstance().retainIconForPageUrl(url);
      c.deactivate();
      setResult(RESULT_OK);
    }
  }
 catch (  IllegalStateException e) {
    setTitle(r.getText(R.string.no_database));
    return false;
  }
  return true;
}