Program: 31839
Project: 31839
Buggy source:
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  if (showMode == 0) {
    drawGridLines(c,canvasWidth * gridDensity / DPRatio,canvasHeight * gridDensity / DPRatio);
    c.concat(matrix);
    c.drawPath(path,linePaint);
    c.restore();
    drawCursor(c);
    drawGridLabels(c);
  }
 else {
    labelBeginX=getLabelBeginX();
    labelBeginY=getLabelBeginY();
    float halfFreqResolutionShift=xZoom * (canvasWidth - labelBeginX) / nFreqPoints / 2;
    matrixSpectrogram.reset();
    if (showFreqAlongX) {
      matrixSpectrogram.postScale(xZoom * (canvasWidth - labelBeginX) / nFreqPoints,labelBeginY / nTimePoints);
      matrixSpectrogram.postTranslate(labelBeginX - xShift * xZoom * (canvasWidth - labelBeginX) + halfFreqResolutionShift,0f);
    }
 else {
      matrixSpectrogram.postRotate(-90);
      matrixSpectrogram.postScale((canvasWidth - labelBeginX) / nTimePoints,yZoom * labelBeginY / nFreqPoints);
      matrixSpectrogram.postTranslate(labelBeginX,(1 - yShift) * yZoom * labelBeginY + halfFreqResolutionShift);
    }
    c.concat(matrixSpectrogram);
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,cursorPaint);
    }
    c.restore();
    drawCursor(c);
    if (showFreqAlongX) {
      drawFreqAxis(c,labelBeginX,labelBeginY,canvasWidth * gridDensity / DPRatio,showFreqAlongX);
      if (labelBeginX > 0) {
        c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
        drawTimeAxis(c,labelBeginX,labelBeginY,canvasHeight * gridDensity / DPRatio,!showFreqAlongX);
      }
    }
 else {
      drawFreqAxis(c,labelBeginX,labelBeginY,canvasHeight * gridDensity / DPRatio,showFreqAlongX);
      if (labelBeginY != canvasHeight) {
        c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
        drawTimeAxis(c,labelBeginX,labelBeginY,canvasWidth * gridDensity / DPRatio,!showFreqAlongX);
      }
    }
  }
  isBusy=false;
}

Fixed version (ground truth):
@Override protected void onDraw(Canvas c){
  isBusy=true;
  c.concat(matrix0);
  c.save();
  if (showMode == 0) {
    drawGridLines(c,canvasWidth * gridDensity / DPRatio,canvasHeight * gridDensity / DPRatio);
    computeMatrix();
    c.concat(matrix);
    c.drawPath(path,linePaint);
    c.restore();
    drawCursor(c);
    drawGridLabels(c);
  }
 else {
    labelBeginX=getLabelBeginX();
    labelBeginY=getLabelBeginY();
    float halfFreqResolutionShift=xZoom * (canvasWidth - labelBeginX) / nFreqPoints / 2;
    matrixSpectrogram.reset();
    if (showFreqAlongX) {
      matrixSpectrogram.postScale(xZoom * (canvasWidth - labelBeginX) / nFreqPoints,labelBeginY / nTimePoints);
      matrixSpectrogram.postTranslate(labelBeginX - xShift * xZoom * (canvasWidth - labelBeginX) + halfFreqResolutionShift,0f);
    }
 else {
      matrixSpectrogram.postRotate(-90);
      matrixSpectrogram.postScale((canvasWidth - labelBeginX) / nTimePoints,yZoom * labelBeginY / nFreqPoints);
      matrixSpectrogram.postTranslate(labelBeginX,(1 - yShift) * yZoom * labelBeginY + halfFreqResolutionShift);
    }
    c.concat(matrixSpectrogram);
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,cursorPaint);
    }
    c.restore();
    drawCursor(c);
    if (showFreqAlongX) {
      drawFreqAxis(c,labelBeginX,labelBeginY,canvasWidth * gridDensity / DPRatio,showFreqAlongX);
      if (labelBeginX > 0) {
        c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
        drawTimeAxis(c,labelBeginX,labelBeginY,canvasHeight * gridDensity / DPRatio,!showFreqAlongX);
      }
    }
 else {
      drawFreqAxis(c,labelBeginX,labelBeginY,canvasHeight * gridDensity / DPRatio,showFreqAlongX);
      if (labelBeginY != canvasHeight) {
        c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
        drawTimeAxis(c,labelBeginX,labelBeginY,canvasWidth * gridDensity / DPRatio,!showFreqAlongX);
      }
    }
  }
  isBusy=false;
}