Program: 154064
Project: 154064
Buggy source:
private int getSample(Object inData,int sample){
  boolean needAlpha=(hasAlpha && isAlphaPremultiplied);
  int type=colorSpaceType;
  boolean is_sRGB=colorSpace.isCS_sRGB();
  if (type == ColorSpace.TYPE_GRAY) {
    sample=0;
    is_sRGB=true;
  }
  if (is_sRGB) {
    if (transferType == DataBuffer.TYPE_FLOAT) {
      float[] fdata=(float[])inData;
      float fsample=fdata[sample] * 255;
      if (needAlpha) {
        float falp=fdata[numColorComponents];
        if (falp == 0.0)         return 0;
 else         return clamp(fsample / falp);
      }
 else {
        return clamp(fsample);
      }
    }
 else {
      double[] ddata=(double[])inData;
      double dsample=ddata[sample] * 255.0;
      if (needAlpha) {
        double dalp=ddata[numColorComponents];
        if (dalp == 0.0)         return 0;
 else         return clamp(dsample / dalp);
      }
 else {
        return clamp(dsample);
      }
    }
  }
  float[] norm;
  float[] rgb;
  if (transferType == DataBuffer.TYPE_FLOAT) {
    float[] fdata=(float[])inData;
    if (needAlpha) {
      float falp=fdata[numColorComponents];
      if (falp == 0.0)       return 0;
      norm=new float[numColorComponents];
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=fdata[i] / falp;
      }
      rgb=colorSpace.toRGB(norm);
    }
 else {
      rgb=colorSpace.toRGB(fdata);
    }
    return (int)(rgb[sample] * 255);
  }
 else {
    double[] ddata=(double[])inData;
    norm=new float[numColorComponents];
    if (needAlpha) {
      double dalp=ddata[numColorComponents];
      if (dalp == 0.0)       return 0;
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=(float)(ddata[i] / dalp);
      }
      rgb=colorSpace.toRGB(norm);
    }
 else {
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=(float)ddata[i];
      }
      rgb=colorSpace.toRGB(norm);
    }
    return (int)(rgb[sample] * 255);
  }
}

Fixed version (ground truth):
private int getSample(Object inData,int sample){
  boolean needAlpha=(hasAlpha && isAlphaPremultiplied);
  int type=colorSpaceType;
  boolean is_sRGB=colorSpace.isCS_sRGB();
  if (type == ColorSpace.TYPE_GRAY) {
    sample=0;
    is_sRGB=true;
  }
  if (is_sRGB) {
    if (transferType == DataBuffer.TYPE_FLOAT) {
      float[] fdata=(float[])inData;
      float fsample=fdata[sample] * 255;
      if (needAlpha) {
        float falp=fdata[numColorComponents];
        if (falp == 0.0)         return 0;
 else         return clamp(fsample / falp);
      }
 else {
        return clamp(fsample);
      }
    }
 else {
      double[] ddata=(double[])inData;
      double dsample=ddata[sample] * 255.0;
      if (needAlpha) {
        double dalp=ddata[numColorComponents];
        if (dalp == 0.0)         return 0;
 else         return clamp(dsample / dalp);
      }
 else {
        return clamp(dsample);
      }
    }
  }
  float[] norm;
  float[] rgb;
  if (transferType == DataBuffer.TYPE_FLOAT) {
    float[] fdata=(float[])inData;
    if (needAlpha) {
      float falp=fdata[numColorComponents];
      if (falp == 0.0)       return 0;
      norm=new float[numColorComponents];
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=fdata[i] / falp;
      }
      rgb=colorSpace.toRGB(norm);
    }
 else {
      rgb=colorSpace.toRGB(fdata);
    }
    return (int)(rgb[sample] * 255 + 0.5F);
  }
 else {
    double[] ddata=(double[])inData;
    norm=new float[numColorComponents];
    if (needAlpha) {
      double dalp=ddata[numColorComponents];
      if (dalp == 0.0)       return 0;
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=(float)(ddata[i] / dalp);
      }
      rgb=colorSpace.toRGB(norm);
    }
 else {
      for (int i=0; i < numColorComponents; i++) {
        norm[i]=(float)ddata[i];
      }
      rgb=colorSpace.toRGB(norm);
    }
    return (int)(rgb[sample] * 255 + 0.5);
  }
}