Program: 54998
Project: 54998
Buggy source:
@Override public boolean onScale(ScaleGestureDetector detector){
  if (source != null) {
    float xScale=detector.getCurrentSpanX() / detector.getPreviousSpanX();
    long frequencyFocus=virtualFrequency + (int)((detector.getFocusX() / width - 0.5) * virtualSampleRate);
    int maxSampleRate=demodulationEnabled ? (int)(source.getSampleRate() * 0.9) : source.getMaxSampleRate();
    virtualSampleRate=(int)Math.min(Math.max(virtualSampleRate / xScale,MIN_VIRTUAL_SAMPLERATE),maxSampleRate);
    virtualFrequency=Math.min(Math.max(frequencyFocus + (long)((virtualFrequency - frequencyFocus) / xScale),source.getMinFrequency() - source.getSampleRate() / 2),source.getMaxFrequency() + source.getSampleRate() / 2);
    if (verticalZoomEnabled) {
      float yScale=detector.getCurrentSpanY() / detector.getPreviousSpanY();
      float dBFocus=maxDB - (maxDB - minDB) * (detector.getFocusY() / getFftHeight());
      float newMinDB=Math.min(Math.max(dBFocus - (dBFocus - minDB) / yScale,MIN_DB),MAX_DB - 10);
      float newMaxDB=Math.min(Math.max(dBFocus - (dBFocus - maxDB) / yScale,newMinDB + 10),MAX_DB);
      this.setDBScale(newMinDB,newMaxDB);
    }
    if (source.getSampleRate() < virtualSampleRate && virtualSampleRate < source.getMaxSampleRate())     source.setSampleRate(source.getNextHigherOptimalSampleRate(virtualSampleRate));
    int nextLower=source.getNextLowerOptimalSampleRate(source.getSampleRate());
    if ((virtualSampleRate < nextLower) && (source.getSampleRate() > nextLower)) {
      source.setSampleRate(nextLower);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onScale(ScaleGestureDetector detector){
  if (source != null) {
    float xScale=detector.getCurrentSpanX() / detector.getPreviousSpanX();
    long frequencyFocus=virtualFrequency + (int)((detector.getFocusX() / width - 0.5) * virtualSampleRate);
    int maxSampleRate=demodulationEnabled ? (int)(source.getSampleRate() * 0.9) : source.getMaxSampleRate();
    virtualSampleRate=(int)Math.min(Math.max(virtualSampleRate / xScale,MIN_VIRTUAL_SAMPLERATE),maxSampleRate);
    virtualFrequency=Math.min(Math.max(frequencyFocus + (long)((virtualFrequency - frequencyFocus) / xScale),source.getMinFrequency() - source.getSampleRate() / 2),source.getMaxFrequency() + source.getSampleRate() / 2);
    if (verticalZoomEnabled) {
      float yScale=detector.getCurrentSpanY() / detector.getPreviousSpanY();
      float dBFocus=maxDB - (maxDB - minDB) * (detector.getFocusY() / getFftHeight());
      float newMinDB=Math.min(Math.max(dBFocus - (dBFocus - minDB) / yScale,MIN_DB),MAX_DB - 10);
      float newMaxDB=Math.min(Math.max(dBFocus - (dBFocus - maxDB) / yScale,newMinDB + 10),MAX_DB);
      this.setDBScale(newMinDB,newMaxDB);
      if (squelch < minDB)       squelch=minDB;
      if (squelch > maxDB)       squelch=maxDB;
    }
    if (source.getSampleRate() < virtualSampleRate && virtualSampleRate < source.getMaxSampleRate())     source.setSampleRate(source.getNextHigherOptimalSampleRate(virtualSampleRate));
    int nextLower=source.getNextLowerOptimalSampleRate(source.getSampleRate());
    if ((virtualSampleRate < nextLower) && (source.getSampleRate() > nextLower)) {
      source.setSampleRate(nextLower);
    }
  }
  return true;
}