Program: 31816
Project: 31816
Buggy source:
void drawSpectrogramPlot(Canvas c){
  labelBeginX=getLabelBeginX();
  labelBeginY=getLabelBeginY();
  if (showFreqAlongX) {
    axisFreq.setNCanvasPixel(canvasWidth - labelBeginX);
    axisTime.setNCanvasPixel(labelBeginY);
  }
 else {
    axisTime.setNCanvasPixel(canvasWidth - labelBeginX);
    axisFreq.setNCanvasPixel(labelBeginY);
  }
  fqGridLabel.setDensity(axisFreq.nCanvasPixel * gridDensity / DPRatio);
  tmGridLabel.setDensity(axisTime.nCanvasPixel * gridDensity / DPRatio);
  float halfFreqResolutionShift;
  matrixSpectrogram.reset();
  if (showFreqAlongX) {
    matrixSpectrogram.postScale(axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints,axisTime.zoom * axisTime.nCanvasPixel / nTimePoints);
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
    matrixSpectrogram.postTranslate((labelBeginX - axisFreq.shift * axisFreq.zoom * axisFreq.nCanvasPixel + halfFreqResolutionShift),-axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel);
  }
 else {
    matrixSpectrogram.postRotate(-90);
    matrixSpectrogram.postScale(axisTime.zoom * axisTime.nCanvasPixel / nTimePoints,axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints);
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
    matrixSpectrogram.postTranslate((labelBeginX - axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel),(1 - axisFreq.shift) * axisFreq.zoom * axisFreq.nCanvasPixel - halfFreqResolutionShift);
  }
  c.concat(matrixSpectrogram);
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LOG) {
    c.scale((float)nFreqPoints / logSegBmp.bmpWidth,1.0f);
    logSegBmp.draw(c);
    if (showModeSpectrogram == 1) {
      c.drawLine(0,logSegBmp.bmPt,logSegBmp.bmpWidth,logSegBmp.bmPt,cursorTimePaint);
    }
  }
 else {
synchronized (this) {
      if (showModeSpectrogram == 0) {
        System.arraycopy(spectrogramColors,0,spectrogramColorsShifting,(nTimePoints - spectrogramColorsPt) * nFreqPoints,spectrogramColorsPt * nFreqPoints);
        System.arraycopy(spectrogramColors,spectrogramColorsPt * nFreqPoints,spectrogramColorsShifting,0,(nTimePoints - spectrogramColorsPt) * nFreqPoints);
        c.drawBitmap(spectrogramColorsShifting,0,nFreqPoints,0,0,nFreqPoints,nTimePoints,false,smoothBmpPaint);
      }
 else {
        c.drawBitmap(spectrogramColors,0,nFreqPoints,0,0,nFreqPoints,nTimePoints,false,smoothBmpPaint);
      }
    }
    if (showModeSpectrogram == 1) {
      c.drawLine(0,spectrogramColorsPt,nFreqPoints,spectrogramColorsPt,cursorTimePaint);
    }
  }
  c.restore();
  drawFreqCursor(c);
  if (showFreqAlongX) {
    c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginX > 0) {
      c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
 else {
    c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginY != canvasHeight) {
      c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
}

Fixed version (ground truth):
void drawSpectrogramPlot(Canvas c){
  labelBeginX=getLabelBeginX();
  labelBeginY=getLabelBeginY();
  if (showFreqAlongX) {
    axisFreq.setNCanvasPixel(canvasWidth - labelBeginX);
    axisTime.setNCanvasPixel(labelBeginY);
  }
 else {
    axisTime.setNCanvasPixel(canvasWidth - labelBeginX);
    axisFreq.setNCanvasPixel(labelBeginY);
  }
  fqGridLabel.setDensity(axisFreq.nCanvasPixel * gridDensity / DPRatio);
  tmGridLabel.setDensity(axisTime.nCanvasPixel * gridDensity / DPRatio);
  float halfFreqResolutionShift;
  matrixSpectrogram.reset();
  if (showFreqAlongX) {
    matrixSpectrogram.postScale(axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints,axisTime.zoom * axisTime.nCanvasPixel / nTimePoints);
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
    matrixSpectrogram.postTranslate((labelBeginX - axisFreq.shift * axisFreq.zoom * axisFreq.nCanvasPixel + halfFreqResolutionShift),-axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel);
  }
 else {
    matrixSpectrogram.postRotate(-90);
    matrixSpectrogram.postScale(axisTime.zoom * axisTime.nCanvasPixel / nTimePoints,axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints);
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
    matrixSpectrogram.postTranslate((labelBeginX - axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel),(1 - axisFreq.shift) * axisFreq.zoom * axisFreq.nCanvasPixel - halfFreqResolutionShift);
  }
  c.concat(matrixSpectrogram);
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LOG) {
    c.scale((float)nFreqPoints / logSegBmp.bmpWidth,1.0f);
synchronized (this) {
      logSegBmp.draw(c);
    }
    if (showModeSpectrogram == 1) {
      c.drawLine(0,logSegBmp.bmPt,logSegBmp.bmpWidth,logSegBmp.bmPt,cursorTimePaint);
    }
  }
 else {
synchronized (this) {
      if (showModeSpectrogram == 0) {
        System.arraycopy(spectrogramColors,0,spectrogramColorsShifting,(nTimePoints - spectrogramColorsPt) * nFreqPoints,spectrogramColorsPt * nFreqPoints);
        System.arraycopy(spectrogramColors,spectrogramColorsPt * nFreqPoints,spectrogramColorsShifting,0,(nTimePoints - spectrogramColorsPt) * nFreqPoints);
        c.drawBitmap(spectrogramColorsShifting,0,nFreqPoints,0,0,nFreqPoints,nTimePoints,false,smoothBmpPaint);
      }
 else {
        c.drawBitmap(spectrogramColors,0,nFreqPoints,0,0,nFreqPoints,nTimePoints,false,smoothBmpPaint);
      }
    }
    if (showModeSpectrogram == 1) {
      c.drawLine(0,spectrogramColorsPt,nFreqPoints,spectrogramColorsPt,cursorTimePaint);
    }
  }
  c.restore();
  drawFreqCursor(c);
  if (showFreqAlongX) {
    c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginX > 0) {
      c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
 else {
    c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginY != canvasHeight) {
      c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
}