#vulnerable code 
                              public static void clearCache(int maxSize) {
    Image first;
    while (images.size() > 0 && currentMemory > maxSize) {
      first = images.remove(0);
      first.bimg = null;
      currentMemory -= first.bsize;
    }
    if (maxSize == 0) {
      currentMemory = 0;
    } else {
      currentMemory = Math.max(0, currentMemory);
    }
  } 
                            #location 6 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                              public static void clearCache(int maxSize) {
    currentMemoryChange(0, maxSize);
  }