Program: 31772
Project: 31772
Buggy source:
double[] setViewRange(double[] _ranges,double[] rangesDefault){
  if (_ranges.length < VIEW_RANGE_DATA_LENGTH) {
    Log.i(TAG,"String_Node_Str");
    return null;
  }
  double[] ranges=new double[VIEW_RANGE_DATA_LENGTH];
  System.arraycopy(_ranges,0,ranges,0,VIEW_RANGE_DATA_LENGTH);
  if (rangesDefault != null) {
    if (rangesDefault.length != 2 * VIEW_RANGE_DATA_LENGTH) {
      Log.i(TAG,"String_Node_Str");
      return null;
    }
    for (int i=0; i < 6; i+=2) {
      if (ranges[i] > ranges[i + 1]) {
        double t=ranges[i];
        ranges[i]=ranges[i + 1];
        ranges[i + 1]=t;
      }
      if (ranges[i] < rangesDefault[i + 6])       ranges[i]=rangesDefault[i + 6];
      if (ranges[i + 1] < rangesDefault[i + 6])       ranges[i + 1]=rangesDefault[i + 7];
      if (ranges[i] > rangesDefault[i + 7])       ranges[i]=rangesDefault[i + 6];
      if (ranges[i + 1] > rangesDefault[i + 7])       ranges[i + 1]=rangesDefault[i + 7];
      if (ranges[i] == ranges[i + 1] || Double.isNaN(ranges[i]) || Double.isNaN(ranges[i + 1])) {
        ranges[i]=rangesDefault[i];
        ranges[i + 1]=rangesDefault[i + 1];
      }
    }
  }
  if (showMode == PlotMode.SPECTRUM) {
    spectrumPlot.axisX.setZoomShiftFromV(ranges[0],ranges[1]);
    spectrumPlot.axisY.setZoomShiftFromV(ranges[3],ranges[2]);
  }
 else   if (showMode == PlotMode.SPECTROGRAM) {
    spectrogramPlot.axisTime.setZoomShiftFromV(ranges[4],ranges[5]);
    if (spectrogramPlot.showFreqAlongX) {
      spectrogramPlot.axisFreq.setZoomShiftFromV(ranges[0],ranges[1]);
    }
 else {
      spectrogramPlot.axisFreq.setZoomShiftFromV(ranges[1],ranges[0]);
    }
    spectrogramPlot.spectrogramBMP.updateAxis(spectrogramPlot.axisFreq);
  }
  if (showMode == PlotMode.SPECTRUM) {
    xZoom=spectrumPlot.axisX.getZoom();
    xShift=spectrumPlot.axisX.getShift();
    yZoom=spectrumPlot.axisY.getZoom();
    yShift=spectrumPlot.axisY.getShift();
  }
 else   if (showMode == PlotMode.SPECTROGRAM) {
    if (spectrogramPlot.showFreqAlongX) {
      xZoom=spectrogramPlot.axisFreq.getZoom();
      xShift=spectrogramPlot.axisFreq.getShift();
      yZoom=spectrogramPlot.axisTime.getZoom();
      yShift=spectrogramPlot.axisTime.getShift();
    }
 else {
      yZoom=spectrogramPlot.axisFreq.getZoom();
      yShift=spectrogramPlot.axisFreq.getShift();
      xZoom=spectrogramPlot.axisTime.getZoom();
      xShift=spectrogramPlot.axisTime.getShift();
    }
  }
  return ranges;
}

Fixed version (ground truth):
double[] setViewRange(double[] _ranges,double[] rangesDefault){
  if (_ranges.length < VIEW_RANGE_DATA_LENGTH) {
    Log.i(TAG,"String_Node_Str");
    return null;
  }
  double[] ranges=new double[VIEW_RANGE_DATA_LENGTH];
  System.arraycopy(_ranges,0,ranges,0,VIEW_RANGE_DATA_LENGTH);
  if (rangesDefault != null) {
    if (rangesDefault.length != 2 * VIEW_RANGE_DATA_LENGTH) {
      Log.i(TAG,"String_Node_Str");
      return null;
    }
    for (int i=0; i < 6; i+=2) {
      if (ranges[i] > ranges[i + 1]) {
        double t=ranges[i];
        ranges[i]=ranges[i + 1];
        ranges[i + 1]=t;
      }
      if (ranges[i] < rangesDefault[i + 6])       ranges[i]=rangesDefault[i + 6];
      if (ranges[i + 1] < rangesDefault[i + 6])       ranges[i + 1]=rangesDefault[i + 7];
      if (ranges[i] > rangesDefault[i + 7])       ranges[i]=rangesDefault[i + 6];
      if (ranges[i + 1] > rangesDefault[i + 7])       ranges[i + 1]=rangesDefault[i + 7];
      if (ranges[i] == ranges[i + 1] || Double.isNaN(ranges[i]) || Double.isNaN(ranges[i + 1])) {
        ranges[i]=rangesDefault[i];
        ranges[i + 1]=rangesDefault[i + 1];
      }
    }
  }
  if (showMode == PlotMode.SPECTRUM) {
    spectrumPlot.axisX.setViewBounds(ranges[0],ranges[1]);
    spectrumPlot.axisY.setViewBounds(ranges[3],ranges[2]);
  }
 else   if (showMode == PlotMode.SPECTROGRAM) {
    spectrogramPlot.axisTime.setViewBounds(ranges[4],ranges[5]);
    if (spectrogramPlot.showFreqAlongX) {
      spectrogramPlot.axisFreq.setViewBounds(ranges[0],ranges[1]);
    }
 else {
      spectrogramPlot.axisFreq.setViewBounds(ranges[1],ranges[0]);
    }
    spectrogramPlot.spectrogramBMP.updateAxis(spectrogramPlot.axisFreq);
  }
  if (showMode == PlotMode.SPECTRUM) {
    xZoom=spectrumPlot.axisX.getZoom();
    xShift=spectrumPlot.axisX.getShift();
    yZoom=spectrumPlot.axisY.getZoom();
    yShift=spectrumPlot.axisY.getShift();
  }
 else   if (showMode == PlotMode.SPECTROGRAM) {
    if (spectrogramPlot.showFreqAlongX) {
      xZoom=spectrogramPlot.axisFreq.getZoom();
      xShift=spectrogramPlot.axisFreq.getShift();
      yZoom=spectrogramPlot.axisTime.getZoom();
      yShift=spectrogramPlot.axisTime.getShift();
    }
 else {
      yZoom=spectrogramPlot.axisFreq.getZoom();
      yShift=spectrogramPlot.axisFreq.getShift();
      xZoom=spectrogramPlot.axisTime.getZoom();
      xShift=spectrogramPlot.axisTime.getShift();
    }
  }
  return ranges;
}