Program: 187916
Project: 187916
Buggy source:
public static void registerManagedService(String serviceClassName,long timeIntervall,boolean useWhileRoaming){
  long minTime=0;
  ContentValues cv=new ContentValues();
  Cursor c=mContentResolver.query(ManagedService.CONTENT_URI,ManagedService.PROJECTION,ManagedService.SERVICE_CLASS + "String_Node_Str" + serviceClassName+ "String_Node_Str",null,null);
  if (c != null && c.count() > 0) {
    c.first();
    c.updateString(c.getColumnIndex(ManagedService.TIME_INTERVALL),Long.toString(timeIntervall));
    c.updateString(c.getColumnIndex(ManagedService.DO_ROAMING),Boolean.toString(useWhileRoaming));
    c.commitUpdates();
    c.close();
  }
 else {
  }
  c=mContentResolver.query(ManagedService.CONTENT_URI,ManagedService.PROJECTION,null,null,null);
  c.first();
  minTime=c.getLong(c.getColumnIndex(ManagedService.TIME_INTERVALL));
  while (!c.isAfterLast()) {
    long l=c.getLong(c.getColumnIndex(ManagedService.TIME_INTERVALL));
    if (l < minTime) {
      minTime=l;
    }
    c.next();
  }
  c.close();
  c=mContentResolver.query(DateTime.CONTENT_URI,DateTime.PROJECTION,DateTime.INTENT + "String_Node_Str" + org.openintents.OpenIntents.SERVICE_MANAGER+ "String_Node_Str",null,null);
  String now="String_Node_Str" + System.currentTimeMillis();
  cv.put(DateTime.TIME,now);
  cv.put(DateTime.REOCCURENCE,minTime);
  cv.put(DateTime.INTENT,org.openintents.OpenIntents.SERVICE_MANAGER);
  cv.put(DateTime.NATURE,Alert.NATURE_SYSTEM);
  cv.put(DateTime.ACTIVATE_ON_BOOT,true);
  cv.put(DateTime.ACTIVE,true);
  cv.put(DateTime.TYPE,Alert.TYPE_DATE_TIME);
  if (c != null && c.count() > 0) {
    update(DateTime.CONTENT_URI,cv,DateTime.INTENT + "String_Node_Str" + org.openintents.OpenIntents.SERVICE_MANAGER+ "String_Node_Str",null);
    alarmManager.cancel(new Intent().setAction(org.openintents.OpenIntents.SERVICE_MANAGER));
    registerDateTimeAlert(cv);
  }
 else {
    insert(DateTime.CONTENT_URI,cv);
  }
}

Fixed version (ground truth):
public static void registerManagedService(String serviceClassName,long timeIntervall,boolean useWhileRoaming){
  long minTime=0;
  ContentValues cv=null;
  Cursor c=mContentResolver.query(ManagedService.CONTENT_URI,ManagedService.PROJECTION,ManagedService.SERVICE_CLASS + "String_Node_Str" + serviceClassName+ "String_Node_Str",null,null);
  if (c != null && c.count() > 0) {
    c.first();
    c.updateString(c.getColumnIndex(ManagedService.TIME_INTERVALL),Long.toString(timeIntervall));
    c.updateString(c.getColumnIndex(ManagedService.DO_ROAMING),Boolean.toString(useWhileRoaming));
    c.commitUpdates();
    c.close();
  }
 else {
    cv=new ContentValues();
    cv.put(ManagedService.SERVICE_CLASS,serviceClassName);
    cv.put(ManagedService.TIME_INTERVALL,timeIntervall);
    cv.put(ManagedService.DO_ROAMING,useWhileRoaming);
    insert(ManagedService.CONTENT_URI,cv);
  }
  c=mContentResolver.query(ManagedService.CONTENT_URI,ManagedService.PROJECTION,null,null,null);
  c.first();
  minTime=c.getLong(c.getColumnIndex(ManagedService.TIME_INTERVALL));
  while (!c.isAfterLast()) {
    long l=c.getLong(c.getColumnIndex(ManagedService.TIME_INTERVALL));
    if (l < minTime) {
      minTime=l;
    }
    c.next();
  }
  c.close();
  c=mContentResolver.query(DateTime.CONTENT_URI,DateTime.PROJECTION,DateTime.INTENT + "String_Node_Str" + org.openintents.OpenIntents.SERVICE_MANAGER+ "String_Node_Str",null,null);
  String now="String_Node_Str" + System.currentTimeMillis();
  cv=new ContentValues();
  cv.put(DateTime.TIME,now);
  cv.put(DateTime.REOCCURENCE,minTime);
  cv.put(DateTime.INTENT,org.openintents.OpenIntents.SERVICE_MANAGER);
  cv.put(DateTime.NATURE,Alert.NATURE_SYSTEM);
  cv.put(DateTime.ACTIVATE_ON_BOOT,true);
  cv.put(DateTime.ACTIVE,true);
  cv.put(DateTime.TYPE,Alert.TYPE_DATE_TIME);
  if (c != null && c.count() > 0) {
    update(DateTime.CONTENT_URI,cv,DateTime.INTENT + "String_Node_Str" + org.openintents.OpenIntents.SERVICE_MANAGER+ "String_Node_Str",null);
    alarmManager.cancel(new Intent().setAction(org.openintents.OpenIntents.SERVICE_MANAGER));
    registerDateTimeAlert(cv);
  }
 else {
    insert(DateTime.CONTENT_URI,cv);
  }
}