Program: 142189
Project: 142189
Buggy source:
/** 
 * Remove form record and associated session state descriptor from storage and delete form instance files linked to the form record.
 */
private static void wipeRecord(Context context,int sessionId,int formRecordId,SqlStorage<FormRecord> frStorage,SqlStorage<SessionStateDescriptor> ssdStorage){
  if (sessionId != -1) {
    try {
      SessionStateDescriptor ssd=ssdStorage.read(sessionId);
      int ssdFrid=ssd.getFormRecordId();
      if (formRecordId == -1) {
        formRecordId=ssdFrid;
      }
 else       if (formRecordId != ssdFrid) {
        Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
      }
    }
 catch (    Exception e) {
      Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
    }
  }
  String dataPath=null;
  if (formRecordId != -1) {
    try {
      FormRecord r=frStorage.read(formRecordId);
      dataPath=r.getPath(context);
      if (sessionId == -1) {
        Vector<Integer> sessionIds=ssdStorage.getIDsForValue(SessionStateDescriptor.META_FORM_RECORD_ID,formRecordId);
        if (sessionIds.size() == 1) {
          sessionId=sessionIds.firstElement();
        }
 else         if (sessionIds.size() > 1) {
          sessionId=sessionIds.firstElement();
          Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
        }
      }
    }
 catch (    Exception e) {
      Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
    }
  }
  if (sessionId != -1) {
    ssdStorage.remove(sessionId);
  }
  if (formRecordId != -1) {
    frStorage.remove(formRecordId);
  }
  if (dataPath != null) {
    String selection=InstanceColumns.INSTANCE_FILE_PATH + "String_Node_Str";
    Cursor c=context.getContentResolver().query(InstanceColumns.CONTENT_URI,new String[]{InstanceColumns._ID},selection,new String[]{dataPath},null);
    if (c.moveToFirst()) {
      long id=c.getLong(0);
      context.getContentResolver().delete(ContentUris.withAppendedId(InstanceColumns.CONTENT_URI,id),null,null);
    }
 else {
      FileUtil.deleteFileOrDir(dataPath);
    }
    c.close();
  }
}

Fixed version (ground truth):
/** 
 * Remove form record and associated session state descriptor from storage and delete form instance files linked to the form record.
 */
private static void wipeRecord(Context context,int sessionId,int formRecordId,SqlStorage<FormRecord> frStorage,SqlStorage<SessionStateDescriptor> ssdStorage){
  if (sessionId != -1) {
    try {
      SessionStateDescriptor ssd=ssdStorage.read(sessionId);
      int ssdFrid=ssd.getFormRecordId();
      if (formRecordId == -1) {
        formRecordId=ssdFrid;
      }
 else       if (formRecordId != ssdFrid) {
        Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
      }
    }
 catch (    Exception e) {
      Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
    }
  }
  String dataPath=null;
  if (formRecordId != -1) {
    try {
      FormRecord r=frStorage.read(formRecordId);
      dataPath=r.getPath(context);
      if (sessionId == -1) {
        Vector<Integer> sessionIds=ssdStorage.getIDsForValue(SessionStateDescriptor.META_FORM_RECORD_ID,formRecordId);
        if (sessionIds.size() == 1) {
          sessionId=sessionIds.firstElement();
        }
 else         if (sessionIds.size() > 1) {
          sessionId=sessionIds.firstElement();
          Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
        }
      }
    }
 catch (    Exception e) {
      Logger.log(AndroidLogger.TYPE_ERROR_ASSERTION,"String_Node_Str");
    }
  }
  if (sessionId != -1) {
    ssdStorage.remove(sessionId);
  }
  if (formRecordId != -1) {
    frStorage.remove(formRecordId);
  }
  if (dataPath != null) {
    String selection=InstanceColumns.INSTANCE_FILE_PATH + "String_Node_Str";
    Cursor c=context.getContentResolver().query(InstanceColumns.CONTENT_URI,new String[]{InstanceColumns._ID},selection,new String[]{dataPath},null);
    try {
      if (c.moveToFirst()) {
        long id=c.getLong(0);
        context.getContentResolver().delete(ContentUris.withAppendedId(InstanceColumns.CONTENT_URI,id),null,null);
      }
 else {
        FileUtil.deleteFileOrDir(dataPath);
      }
    }
  finally {
      c.close();
    }
  }
}