Program: 26186
Project: 26186
Buggy source:
@Override protected Exception doInBackground(Object... params){
  DatabaseConnectionOrm dbConn=new DatabaseConnectionOrm(context);
  try {
    dbConn.clearDatabaseOverSize();
    long lastModified=dbConn.getLastModified();
    long offset=dbConn.getLowestItemId(false);
    int requestCount;
    int maxSyncSize=Integer.parseInt(OwnCloudReaderMethods.maxSizePerSync);
    highestItemIdBeforeSync=dbConn.getHighestItemId();
    SharedPreferences mPrefs=PreferenceManager.getDefaultSharedPreferences(context);
    if (lastModified == 0) {
      int maxItemsInDatabase=Constants.maxItemsCount;
      do {
        requestCount=api.GetItems(TAGS.ALL,context,String.valueOf(offset),false,0,"String_Node_Str",api);
        if (requestCount > 0)         offset=dbConn.getLowestItemId(false);
        totalCount+=requestCount;
        publishProgress((Void)null);
      }
 while (requestCount == maxSyncSize);
      mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING,totalCount).commit();
      do {
        offset=dbConn.getLowestItemId(true);
        requestCount=api.GetItems(TAGS.ALL_STARRED,context,String.valueOf(offset),true,0,"String_Node_Str",api);
        totalCount+=requestCount;
      }
 while (requestCount == maxSyncSize && totalCount < maxItemsInDatabase);
    }
 else {
      int[] result=api.GetUpdatedItems(TAGS.ALL,context,lastModified + 1,api);
      mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING,result[1]).commit();
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    return ex;
  }
 finally {
  }
  return null;
}

Fixed version (ground truth):
@Override protected Exception doInBackground(Object... params){
  DatabaseConnectionOrm dbConn=new DatabaseConnectionOrm(context);
  try {
    dbConn.clearDatabaseOverSize();
    long lastModified=dbConn.getLastModified();
    long offset=dbConn.getLowestItemId(false);
    int requestCount;
    int maxSyncSize=Integer.parseInt(OwnCloudReaderMethods.maxSizePerSync);
    highestItemIdBeforeSync=dbConn.getHighestItemId();
    SharedPreferences mPrefs=PreferenceManager.getDefaultSharedPreferences(context);
    if (lastModified == 0) {
      int maxItemsInDatabase=Constants.maxItemsCount;
      do {
        requestCount=api.GetItems(TAGS.ALL,context,String.valueOf(offset),false,0,"String_Node_Str",api);
        if (requestCount > 0)         offset=dbConn.getLowestItemId(false);
        totalCount+=requestCount;
        publishProgress((Void)null);
      }
 while (requestCount == maxSyncSize);
      mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING,totalCount).commit();
      do {
        offset=dbConn.getLowestItemId(true);
        requestCount=api.GetItems(TAGS.ALL_STARRED,context,String.valueOf(offset),true,0,"String_Node_Str",api);
        totalCount+=requestCount;
      }
 while (requestCount == maxSyncSize && totalCount < maxItemsInDatabase);
    }
 else {
      mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING,0).commit();
      int[] result=api.GetUpdatedItems(TAGS.ALL,context,lastModified + 1,api);
      mPrefs.edit().putInt(Constants.LAST_UPDATE_NEW_ITEMS_COUNT_STRING,result[1]).commit();
    }
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    return ex;
  }
 finally {
  }
  return null;
}