nus-yam/ex-repair huggingface dataset:
Program: 52583
Project: 52583
Buggy source:
/** 
 * Encode this   {@link HeartbeatMessage} to an {@link OutputStream}.
 * @param output the  {@link OutputStream} to encode to.
 * @throws IOException
 */
public void encode(TlsContext context,OutputStream output) throws IOException {
  TlsUtils.writeUint8(type,output);
  if (payload == null) {
    TlsUtils.writeUint16(0,output);
  }
 else {
    TlsUtils.checkUint16(payload.length);
    TlsUtils.writeUint16(payload.length,output);
    output.write(payload);
  }
  byte[] padding=new byte[paddingLength];
  context.getSecureRandom().nextBytes(padding);
  output.write(padding);
}

Fixed version (ground truth):
/** 
 * Encode this   {@link HeartbeatMessage} to an {@link OutputStream}.
 * @param output the  {@link OutputStream} to encode to.
 * @throws IOException
 */
public void encode(TlsContext context,OutputStream output) throws IOException {
  TlsUtils.writeUint8(type,output);
  TlsUtils.checkUint16(payload.length);
  TlsUtils.writeUint16(payload.length,output);
  output.write(payload);
  byte[] padding=new byte[paddingLength];
  context.getSecureRandom().nextBytes(padding);
  output.write(padding);
}
Program: 52585
Project: 52585
Buggy source:
public static void main(String[] args) throws Exception {
  InetAddress address=InetAddress.getLocalHost();
  int port=5556;
  TlsSession session=null;
  MockDTLSClient client=new MockDTLSClient(session);
  DTLSTransport dtls=openDTLSConnection(address,port,client);
  System.out.println("String_Node_Str" + dtls.getReceiveLimit());
  System.out.println("String_Node_Str" + dtls.getSendLimit());
  byte[] request="String_Node_Str".getBytes("String_Node_Str");
  dtls.send(request,0,request.length);
  byte[] response=new byte[dtls.getReceiveLimit()];
  int received=dtls.receive(response,0,response.length,30000);
  if (received >= 0) {
    System.out.println(new String(response,0,received,"String_Node_Str"));
  }
  dtls.close();
}

Fixed version (ground truth):
public static void main(String[] args) throws Exception {
  InetAddress address=InetAddress.getLocalHost();
  int port=5556;
  TlsSession session=createSession(address,port);
  MockDTLSClient client=new MockDTLSClient(session);
  DTLSTransport dtls=openDTLSConnection(address,port,client);
  System.out.println("String_Node_Str" + dtls.getReceiveLimit());
  System.out.println("String_Node_Str" + dtls.getSendLimit());
  byte[] request="String_Node_Str".getBytes("String_Node_Str");
  dtls.send(request,0,request.length);
  byte[] response=new byte[dtls.getReceiveLimit()];
  int received=dtls.receive(response,0,response.length,30000);
  if (received >= 0) {
    System.out.println(new String(response,0,received,"String_Node_Str"));
  }
  dtls.close();
}
Program: 52586
Project: 52586
Buggy source:
/** 
 * Add some data to our buffer.
 * @param data   A byte-array to read data from.
 * @param offset How many bytes to skip at the beginning of the array.
 * @param len    How many bytes to read from the array.
 */
public void addData(byte[] data,int offset,int len){
  if ((skipped + available + len) > databuf.length) {
    byte[] tmp=new byte[ByteQueue.nextTwoPow(data.length)];
    System.arraycopy(databuf,skipped,tmp,0,available);
    skipped=0;
    databuf=tmp;
  }
  System.arraycopy(data,offset,databuf,skipped + available,len);
  available+=len;
}

Fixed version (ground truth):
/** 
 * Add some data to our buffer.
 * @param data   A byte-array to read data from.
 * @param offset How many bytes to skip at the beginning of the array.
 * @param len    How many bytes to read from the array.
 */
public void addData(byte[] data,int offset,int len){
  if ((skipped + available + len) > databuf.length) {
    int desiredSize=ByteQueue.nextTwoPow(available + len);
    if (desiredSize > databuf.length) {
      byte[] tmp=new byte[desiredSize];
      System.arraycopy(databuf,skipped,tmp,0,available);
      databuf=tmp;
    }
 else {
      System.arraycopy(databuf,skipped,databuf,0,available);
    }
    skipped=0;
  }
  System.arraycopy(data,offset,databuf,skipped + available,len);
  available+=len;
}
Program: 52587
Project: 52587
Buggy source:
/** 
 * Remove some bytes from our data from the beginning.
 * @param i How many bytes to remove.
 */
public void removeData(int i){
  if (i > available) {
    throw new TlsRuntimeException("String_Node_Str" + i + "String_Node_Str"+ available);
  }
  available-=i;
  skipped+=i;
  if (skipped > (databuf.length / 2)) {
    System.arraycopy(databuf,skipped,databuf,0,available);
    skipped=0;
  }
}

Fixed version (ground truth):
/** 
 * Remove some bytes from our data from the beginning.
 * @param i How many bytes to remove.
 */
public void removeData(int i){
  if (i > available) {
    throw new TlsRuntimeException("String_Node_Str" + i + "String_Node_Str"+ available);
  }
  available-=i;
  skipped+=i;
}
Program: 52588
Project: 52588
Buggy source:
public void encode(BCPGOutputStream out) throws IOException {
  byte[] oid=this.oid.getEncoded();
  out.write(oid.length);
  out.write(oid);
  MPInteger point=new MPInteger(new BigInteger(1,this.point.getEncoded()));
  out.writeObject(point);
}

Fixed version (ground truth):
public void encode(BCPGOutputStream out) throws IOException {
  byte[] oid=this.oid.getEncoded();
  out.write(oid,1,oid.length - 1);
  MPInteger point=new MPInteger(new BigInteger(1,this.point.getEncoded()));
  out.writeObject(point);
}
Program: 52590
Project: 52590
Buggy source:
public OAEPEncoding(AsymmetricBlockCipher cipher,Digest hash,Digest mgf1Hash,byte[] encodingParams){
  this.engine=cipher;
  this.hash=hash;
  this.mgf1Hash=mgf1Hash;
  this.defHash=new byte[hash.getDigestSize()];
  if (encodingParams != null) {
    hash.update(encodingParams,0,encodingParams.length);
  }
  hash.doFinal(defHash,0);
}

Fixed version (ground truth):
public OAEPEncoding(AsymmetricBlockCipher cipher,Digest hash,Digest mgf1Hash,byte[] encodingParams){
  this.engine=cipher;
  this.mgf1Hash=mgf1Hash;
  this.defHash=new byte[hash.getDigestSize()];
  hash.reset();
  if (encodingParams != null) {
    hash.update(encodingParams,0,encodingParams.length);
  }
  hash.doFinal(defHash,0);
}
Program: 52591
Project: 52591
Buggy source:
/** 
 * mask generator function, as described in PKCS1v2.
 */
private byte[] maskGeneratorFunction1(byte[] Z,int zOff,int zLen,int length){
  byte[] mask=new byte[length];
  byte[] hashBuf=new byte[mgf1Hash.getDigestSize()];
  byte[] C=new byte[4];
  int counter=0;
  hash.reset();
  do {
    ItoOSP(counter,C);
    mgf1Hash.update(Z,zOff,zLen);
    mgf1Hash.update(C,0,C.length);
    mgf1Hash.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,mask,counter * hashBuf.length,hashBuf.length);
  }
 while (++counter < (length / hashBuf.length));
  if ((counter * hashBuf.length) < length) {
    ItoOSP(counter,C);
    mgf1Hash.update(Z,zOff,zLen);
    mgf1Hash.update(C,0,C.length);
    mgf1Hash.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,mask,counter * hashBuf.length,mask.length - (counter * hashBuf.length));
  }
  return mask;
}

Fixed version (ground truth):
/** 
 * mask generator function, as described in PKCS1v2.
 */
private byte[] maskGeneratorFunction1(byte[] Z,int zOff,int zLen,int length){
  byte[] mask=new byte[length];
  byte[] hashBuf=new byte[mgf1Hash.getDigestSize()];
  byte[] C=new byte[4];
  int counter=0;
  mgf1Hash.reset();
  while (counter < (length / hashBuf.length)) {
    ItoOSP(counter,C);
    mgf1Hash.update(Z,zOff,zLen);
    mgf1Hash.update(C,0,C.length);
    mgf1Hash.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,mask,counter * hashBuf.length,hashBuf.length);
    counter++;
  }
  if ((counter * hashBuf.length) < length) {
    ItoOSP(counter,C);
    mgf1Hash.update(Z,zOff,zLen);
    mgf1Hash.update(C,0,C.length);
    mgf1Hash.doFinal(hashBuf,0);
    System.arraycopy(hashBuf,0,mask,counter * hashBuf.length,mask.length - (counter * hashBuf.length));
  }
  return mask;
}
Program: 52593
Project: 52593
Buggy source:
public int generate(byte[] output,byte[] additionalInput,boolean predictionResistant){
  int numberOfBits=output.length * 8;
  if (predictionResistant) {
    reseed(additionalInput);
  }
  if (additionalInput != null) {
    hmac_DRBG_Update(additionalInput);
  }
  byte[] rv=new byte[output.length];
  int m=output.length / _V.length;
  _hMac.init(new KeyParameter(_K));
  for (int i=0; i < m; i++) {
    _hMac.update(_V,0,_V.length);
    _hMac.doFinal(_V,0);
    System.arraycopy(_V,0,rv,i * _V.length,_V.length);
  }
  if (m * _V.length < rv.length) {
    _hMac.update(_V,0,_V.length);
    _hMac.doFinal(_V,0);
    System.arraycopy(_V,0,rv,m * _V.length,rv.length - (m * _V.length));
  }
  hmac_DRBG_Update(additionalInput);
  _reseedCounter++;
  System.arraycopy(rv,0,output,0,output.length);
  return numberOfBits;
}

Fixed version (ground truth):
public int generate(byte[] output,byte[] additionalInput,boolean predictionResistant){
  int numberOfBits=output.length * 8;
  if (predictionResistant) {
    reseed(additionalInput);
    additionalInput=null;
  }
  if (additionalInput != null) {
    hmac_DRBG_Update(additionalInput);
  }
  byte[] rv=new byte[output.length];
  int m=output.length / _V.length;
  _hMac.init(new KeyParameter(_K));
  for (int i=0; i < m; i++) {
    _hMac.update(_V,0,_V.length);
    _hMac.doFinal(_V,0);
    System.arraycopy(_V,0,rv,i * _V.length,_V.length);
  }
  if (m * _V.length < rv.length) {
    _hMac.update(_V,0,_V.length);
    _hMac.doFinal(_V,0);
    System.arraycopy(_V,0,rv,m * _V.length,rv.length - (m * _V.length));
  }
  hmac_DRBG_Update(additionalInput);
  _reseedCounter++;
  System.arraycopy(rv,0,output,0,output.length);
  return numberOfBits;
}
Program: 52595
Project: 52595
Buggy source:
public void performTest() throws Exception {
  DRBGTestVector[] tests=createTestVectorData();
  for (int i=0; i != tests.length; i++) {
    DRBGTestVector tv=tests[i];
    byte[] nonce=Hex.decode(tv.nonce());
    byte[] personalisationString=Hex.decode(tv.personalizationString());
    SP80090DRBG d=new DualECSP800DRBG(tv.getDigest(),tv.entropySource(),nonce,personalisationString,tv.securityStrength());
    byte[] output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(0),tv.predictionResistance());
    byte[] expected=tv.expectedValue(0);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(0)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
    output=new byte[tv.expectedValue(1).length];
    d.generate(output,tv.additionalInput(1),tv.predictionResistance());
    expected=tv.expectedValue(1);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(1)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
  }
}

Fixed version (ground truth):
public void performTest() throws Exception {
  DRBGTestVector[] tests=createTestVectorData();
  for (int i=0; i != tests.length; i++) {
    DRBGTestVector tv=tests[i];
    byte[] nonce=tv.nonce();
    byte[] personalisationString=tv.personalizationString();
    SP80090DRBG d=new DualECSP800DRBG(tv.getDigest(),tv.entropySource(),nonce,personalisationString,tv.securityStrength());
    byte[] output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(0),tv.predictionResistance());
    byte[] expected=tv.expectedValue(0);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(0)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
    output=new byte[tv.expectedValue(1).length];
    d.generate(output,tv.additionalInput(1),tv.predictionResistance());
    expected=tv.expectedValue(1);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(1)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
  }
}
Program: 52596
Project: 52596
Buggy source:
public void performTest() throws Exception {
  DRBGTestVector[] tests=createTestVectorData();
  for (int i=0; i != tests.length; i++) {
    DRBGTestVector tv=tests[i];
    byte[] nonce=Hex.decode(tv.nonce());
    byte[] personalisationString=Hex.decode(tv.personalizationString());
    SP80090DRBG d=new HMacSP800DRBG(new HMac(tv.getDigest()),tv.entropySource(),nonce,personalisationString,tv.securityStrength());
    byte[] output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(0),tv.predictionResistance());
    byte[] expected=tv.expectedValue(0);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(0)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
    output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(1),tv.predictionResistance());
    expected=tv.expectedValue(1);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(1)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
  }
}

Fixed version (ground truth):
public void performTest() throws Exception {
  DRBGTestVector[] tests=createTestVectorData();
  for (int i=0; i != tests.length; i++) {
    DRBGTestVector tv=tests[i];
    byte[] nonce=tv.nonce();
    byte[] personalisationString=tv.personalizationString();
    SP80090DRBG d=new HMacSP800DRBG(new HMac(tv.getDigest()),tv.entropySource(),nonce,personalisationString,tv.securityStrength());
    byte[] output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(0),tv.predictionResistance());
    byte[] expected=tv.expectedValue(0);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(0)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
    output=new byte[tv.expectedValue(0).length];
    d.generate(output,tv.additionalInput(1),tv.predictionResistance());
    expected=tv.expectedValue(1);
    if (!areEqual(expected,output)) {
      fail("String_Node_Str" + (i + 1) + "String_Node_Str"+ new String(Hex.encode(tv.expectedValue(1)))+ "String_Node_Str"+ new String(Hex.encode(output)));
    }
  }
}
Program: 52597
Project: 52597
Buggy source:
/** 
 * initialize the distributed leaf calculation reset i,j and compute OTSseed with seed0
 * @param seed0 the starting seed
 */
public void initLeafCalc(byte[] seed0){
  this.i=0;
  this.j=0;
  byte[] dummy=new byte[mdsize];
  System.arraycopy(seed0,0,dummy,0,seed.length);
  this.seed=gmssRandom.nextSeed(dummy);
}

Fixed version (ground truth):
/** 
 * initialize the distributed leaf calculation reset i,j and compute OTSseed with seed0
 * @param seed0 the starting seed
 */
void initLeafCalc(byte[] seed0){
  this.i=0;
  this.j=0;
  byte[] dummy=new byte[mdsize];
  System.arraycopy(seed0,0,dummy,0,seed.length);
  this.seed=gmssRandom.nextSeed(dummy);
}
Program: 52598
Project: 52598
Buggy source:
/** 
 * Processes <code>steps</code> steps of distributed leaf calculation
 * @return true if leaf is completed, else false
 */
public boolean updateLeafCalc(){
  for (int s=0; s < steps; s++) {
    if (i == keysize && j == two_power_w - 1) {
      messDigestOTS.update(concHashs,0,concHashs.length);
      leaf=new byte[messDigestOTS.getDigestSize()];
      messDigestOTS.doFinal(leaf,0);
      return true;
    }
 else     if (i == 0 || j == two_power_w - 1) {
      i++;
      j=0;
      this.privateKeyOTS=gmssRandom.nextSeed(seed);
    }
 else {
      messDigestOTS.update(privateKeyOTS,0,privateKeyOTS.length);
      privateKeyOTS=new byte[messDigestOTS.getDigestSize()];
      messDigestOTS.doFinal(privateKeyOTS,0);
      j++;
      if (j == two_power_w - 1) {
        System.arraycopy(privateKeyOTS,0,concHashs,mdsize * (i - 1),mdsize);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Processes <code>steps</code> steps of distributed leaf calculation
 * @return true if leaf is completed, else false
 */
private void updateLeafCalc(){
  byte[] buf=new byte[messDigestOTS.getDigestSize()];
  for (int s=0; s < steps + 10000; s++) {
    if (i == keysize && j == two_power_w - 1) {
      messDigestOTS.update(concHashs,0,concHashs.length);
      leaf=new byte[messDigestOTS.getDigestSize()];
      messDigestOTS.doFinal(leaf,0);
      return;
    }
 else     if (i == 0 || j == two_power_w - 1) {
      i++;
      j=0;
      this.privateKeyOTS=gmssRandom.nextSeed(seed);
    }
 else {
      messDigestOTS.update(privateKeyOTS,0,privateKeyOTS.length);
      privateKeyOTS=buf;
      messDigestOTS.doFinal(privateKeyOTS,0);
      j++;
      if (j == two_power_w - 1) {
        System.arraycopy(privateKeyOTS,0,concHashs,mdsize * (i - 1),mdsize);
      }
    }
  }
  throw new IllegalStateException("String_Node_Str" + steps + "String_Node_Str"+ i+ "String_Node_Str"+ j);
}
Program: 52599
Project: 52599
Buggy source:
/** 
 * The constructor precomputes some needed variables for distributed leaf calculation
 * @param digest     an array of strings, containing the digest of the used hashfunction and PRNG and the digest of the corresponding provider
 * @param w        the winterniz parameter of that tree the leaf is computedfor
 * @param numLeafs the number of leafs of the tree from where the distributedcomputation is called
 */
public GMSSLeaf(Digest digest,int w,int numLeafs){
  this.w=w;
  messDigestOTS=digest;
  gmssRandom=new GMSSRandom(messDigestOTS);
  mdsize=messDigestOTS.getDigestSize();
  int mdsizeBit=mdsize << 3;
  int messagesize=(int)Math.ceil((double)(mdsizeBit) / (double)w);
  int checksumsize=getLog((messagesize << w) + 1);
  this.keysize=messagesize + (int)Math.ceil((double)checksumsize / (double)w);
  this.two_power_w=1 << w;
  this.steps=(int)Math.ceil((double)(((1 << w) - 1) * keysize + 1 + keysize) / (double)(numLeafs));
  this.seed=new byte[mdsize];
  this.leaf=new byte[mdsize];
  this.privateKeyOTS=new byte[mdsize];
  this.concHashs=new byte[mdsize * keysize];
}

Fixed version (ground truth):
private GMSSLeaf(GMSSLeaf original){
  this.messDigestOTS=original.messDigestOTS;
  this.mdsize=original.mdsize;
  this.keysize=original.keysize;
  this.gmssRandom=original.gmssRandom;
  this.leaf=Arrays.clone(original.leaf);
  this.concHashs=Arrays.clone(original.concHashs);
  this.i=original.i;
  this.j=original.j;
  this.two_power_w=original.two_power_w;
  this.w=original.w;
  this.steps=original.steps;
  this.seed=Arrays.clone(original.seed);
  this.privateKeyOTS=Arrays.clone(original.privateKeyOTS);
}
Program: 52600
Project: 52600
Buggy source:
int generate(byte[] output,byte[] additionalInput,int inOff,int inLen);

Fixed version (ground truth):
int generate(byte[] output,byte[] additionalInput,boolean predictionResistant);
Program: 52601
Project: 52601
Buggy source:
private byte[] hashDFProcess(Digest digest,int bitLength,byte[] inputString){
  byte[] temp=new byte[bitLength / 8];
  int len=temp.length / digest.getDigestSize();
  int counter=1;
  byte[] dig=new byte[digest.getDigestSize()];
  for (int i=0; i <= len; i++) {
    digest.update((byte)(counter >> 24));
    digest.update((byte)(counter >> 16));
    digest.update((byte)(counter >> 8));
    digest.update((byte)counter);
    digest.update((byte)(bitLength >> 24));
    digest.update((byte)(bitLength >> 16));
    digest.update((byte)(bitLength >> 8));
    digest.update((byte)bitLength);
    digest.update(inputString,0,inputString.length);
    digest.doFinal(dig,0);
    int bytesToCopy=((temp.length - i * dig.length) > dig.length) ? dig.length : (temp.length - i * dig.length);
    System.arraycopy(dig,0,temp,i * dig.length,bytesToCopy);
    counter++;
  }
  return temp;
}

Fixed version (ground truth):
private byte[] hashDFProcess(Digest digest,int bitLength,byte[] inputString){
  byte[] temp=new byte[bitLength / 8];
  int len=temp.length / digest.getDigestSize();
  int counter=1;
  byte[] dig=new byte[digest.getDigestSize()];
  for (int i=0; i <= len; i++) {
    digest.update((byte)counter);
    digest.update((byte)(bitLength >> 24));
    digest.update((byte)(bitLength >> 16));
    digest.update((byte)(bitLength >> 8));
    digest.update((byte)bitLength);
    digest.update(inputString,0,inputString.length);
    digest.doFinal(dig,0);
    int bytesToCopy=((temp.length - i * dig.length) > dig.length) ? dig.length : (temp.length - i * dig.length);
    System.arraycopy(dig,0,temp,i * dig.length,bytesToCopy);
    counter++;
  }
  return temp;
}
Program: 52602
Project: 52602
Buggy source:
public SP800DRBG(DRBGDerivationFunction function,EntropySource entropySource,byte[] nonce,byte[] personalisationString,int securityStrength){
  if (securityStrength > function.getSecurityStrength()) {
    throw new IllegalStateException("String_Node_Str");
  }
  _function=function;
  int entropyLengthInBytes=securityStrength;
  byte[] entropy=entropySource.getEntropy(entropyLengthInBytes);
  byte[] seedMaterial=new byte[entropy.length + nonce.length + personalisationString.length];
  System.arraycopy(entropy,0,seedMaterial,0,entropy.length);
  System.arraycopy(nonce,0,seedMaterial,entropy.length,nonce.length);
  System.arraycopy(personalisationString,0,seedMaterial,entropy.length + nonce.length,personalisationString.length);
  byte[] seed=function.getDFBytes(seedMaterial,function.getSeedlength());
  _V=seed;
  byte[] subV=new byte[_V.length + 1];
  System.arraycopy(_V,0,subV,1,_V.length);
  _C=function.getDFBytes(subV,function.getSeedlength());
  _reseedCounter=1;
}

Fixed version (ground truth):
public SP800DRBG(DRBGDerivationFunction function,EntropySource entropySource,byte[] nonce,byte[] personalisationString,int securityStrength){
  if (securityStrength > function.getSecurityStrength()) {
    throw new IllegalStateException("String_Node_Str");
  }
  _function=function;
  _entropySource=entropySource;
  _securityStrength=securityStrength;
  int entropyLengthInBytes=securityStrength;
  byte[] entropy=entropySource.getEntropy(entropyLengthInBytes / 8);
  System.out.println("String_Node_Str" + new String(Hex.encode(entropy)));
  byte[] seedMaterial=new byte[entropy.length + nonce.length + personalisationString.length];
  System.arraycopy(entropy,0,seedMaterial,0,entropy.length);
  System.arraycopy(nonce,0,seedMaterial,entropy.length,nonce.length);
  System.arraycopy(personalisationString,0,seedMaterial,entropy.length + nonce.length,personalisationString.length);
  System.out.println("String_Node_Str" + new String(Hex.encode(seedMaterial)));
  byte[] seed=function.getDFBytes(seedMaterial,function.getSeedlength());
  System.out.println("String_Node_Str" + new String(Hex.encode(seed)));
  _V=seed;
  byte[] subV=new byte[_V.length + 1];
  System.arraycopy(_V,0,subV,1,_V.length);
  _C=function.getDFBytes(subV,function.getSeedlength());
  _reseedCounter=1;
  System.out.println("String_Node_Str" + new String(Hex.encode(_C)));
}
Program: 52603
Project: 52603
Buggy source:
public void reseed(byte[] additionalInput){
}

Fixed version (ground truth):
public void reseed(byte[] additionalInput){
  if (additionalInput == null) {
    additionalInput=new byte[0];
  }
  int entropyLengthInBytes=_securityStrength;
  byte[] entropy=_entropySource.getEntropy(entropyLengthInBytes / 8);
  System.out.println("String_Node_Str" + new String(Hex.encode(entropy)));
  byte[] seedMaterial=new byte[1 + _V.length + entropy.length+ additionalInput.length];
  seedMaterial[0]=0x01;
  System.arraycopy(_V,0,seedMaterial,1,_V.length);
  System.arraycopy(entropy,0,seedMaterial,1 + _V.length,entropy.length);
  System.arraycopy(additionalInput,0,seedMaterial,1 + _V.length + entropy.length,additionalInput.length);
  System.out.println("String_Node_Str" + new String(Hex.encode(seedMaterial)));
  byte[] seed=_function.getDFBytes(seedMaterial,_function.getSeedlength());
  System.out.println("String_Node_Str" + new String(Hex.encode(seed)));
  _V=seed;
  byte[] subV=new byte[_V.length + 1];
  subV[0]=0x00;
  System.arraycopy(_V,0,subV,1,_V.length);
  _C=_function.getDFBytes(subV,_function.getSeedlength());
  _reseedCounter=1;
  System.out.println("String_Node_Str" + new String(Hex.encode(_C)));
}
Program: 52604
Project: 52604
Buggy source:
public int generate(byte[] output,byte[] additionalInput,int inOff,int inLen){
  int numberOfBits=output.length * 8;
  if (_reseedCounter > 10) {
    return 0;
  }
  if (additionalInput != null) {
    byte[] newInput=new byte[1 + _V.length + additionalInput.length];
    newInput[0]=0x02;
    System.arraycopy(_V,0,newInput,1,_V.length);
    System.arraycopy(additionalInput,0,newInput,1 + _V.length,additionalInput.length);
    byte[] w=_function.getBytes(newInput);
    addTo(_V,w);
  }
  byte[] rv=_function.getByteGen(_V,numberOfBits);
  byte[] subH=new byte[_V.length + 1];
  System.arraycopy(_V,0,subH,1,_V.length);
  subH[0]=0x03;
  byte[] H=_function.getBytes(subH);
  addTo(_V,H);
  addTo(_V,_C);
  byte[] c=new byte[4];
  c[0]=(byte)(_reseedCounter >> 24);
  c[1]=(byte)(_reseedCounter >> 16);
  c[2]=(byte)(_reseedCounter >> 8);
  c[3]=(byte)_reseedCounter;
  addTo(_V,c);
  _reseedCounter++;
  System.arraycopy(rv,0,output,0,output.length);
  return numberOfBits;
}

Fixed version (ground truth):
public int generate(byte[] output,byte[] additionalInput,boolean predictionResistant){
  int numberOfBits=output.length * 8;
  if (predictionResistant) {
    reseed(additionalInput);
  }
  if (additionalInput != null) {
    byte[] newInput=new byte[1 + _V.length + additionalInput.length];
    newInput[0]=0x02;
    System.arraycopy(_V,0,newInput,1,_V.length);
    System.arraycopy(additionalInput,0,newInput,1 + _V.length,additionalInput.length);
    byte[] w=_function.getBytes(newInput);
    addTo(_V,w);
  }
  byte[] rv=_function.getByteGen(_V,numberOfBits);
  byte[] subH=new byte[_V.length + 1];
  System.arraycopy(_V,0,subH,1,_V.length);
  subH[0]=0x03;
  byte[] H=_function.getBytes(subH);
  addTo(_V,H);
  addTo(_V,_C);
  byte[] c=new byte[4];
  c[0]=(byte)(_reseedCounter >> 24);
  c[1]=(byte)(_reseedCounter >> 16);
  c[2]=(byte)(_reseedCounter >> 8);
  c[3]=(byte)_reseedCounter;
  addTo(_V,c);
  _reseedCounter++;
  System.arraycopy(rv,0,output,0,output.length);
  System.out.println("String_Node_Str" + new String(Hex.encode(_V)));
  return numberOfBits;
}
Program: 52605
Project: 52605
Buggy source:
public void performTest() throws Exception {
  Digest digest=new SHA512Digest();
  HashDerivationFunction hf=new HashDerivationFunction(digest,888);
  EntropySource entropySource=new BasicEntropySource(new SecureRandom(),false);
  byte[] nonce=new byte[0];
  byte[] personalisationString=new byte[0];
  int securityStrength=128;
  DRBG d=new SP800DRBG(hf,entropySource,nonce,personalisationString,securityStrength);
  byte[] output=new byte[10];
  int rv=d.generate(output,null,0,0);
  String out=new String(Hex.encode(output));
  System.out.println(out);
  for (int i=out.length() - 1; i >= 0; i--) {
    if (out.charAt(i) != '0') {
      System.out.println(i);
      return;
    }
  }
}

Fixed version (ground truth):
public void performTest() throws Exception {
  Digest digest=new SHA1Digest();
  HashDerivationFunction hf=new HashDerivationFunction(digest,440);
  EntropySource tes=new TestEntropySource(Hex.decode("String_Node_Str"),true);
  byte[] nonce=Hex.decode("String_Node_Str");
  byte[] personalisationString=new byte[0];
  int securityStrength=128;
  DRBG d=new SP800DRBG(hf,tes,nonce,personalisationString,securityStrength);
  byte[] output=new byte[20];
  int rv=d.generate(output,null,true);
  String out=new String(Hex.encode(output));
  System.out.println(out);
  rv=d.generate(output,null,true);
  out=new String(Hex.encode(output));
  System.out.println(out);
}
Program: 52606
Project: 52606
Buggy source:
public WebScrollPane(final Component view,final boolean drawBorder,final boolean drawInnerBorder){
  super(view);
  setDrawBorder(drawBorder);
  getWebHorizontalScrollBar().setPaintTrack(drawInnerBorder);
  getWebVerticalScrollBar().setPaintTrack(drawInnerBorder);
  if (!drawInnerBorder) {
    setCorner(JScrollPane.LOWER_RIGHT_CORNER,null);
  }
}

Fixed version (ground truth):
public WebScrollPane(final Component view,final boolean drawBorder,final boolean drawInnerBorder){
  super(view);
  setDrawBorder(drawBorder);
  getWebHorizontalScrollBar().setPaintTrack(drawInnerBorder);
  getWebHorizontalScrollBar().setUnitIncrement(16);
  getWebVerticalScrollBar().setPaintTrack(drawInnerBorder);
  getWebVerticalScrollBar().setUnitIncrement(16);
  if (!drawInnerBorder) {
    setCorner(JScrollPane.LOWER_RIGHT_CORNER,null);
  }
}
Program: 52608
Project: 52608
Buggy source:
/** 
 * Returns list of selected files.
 * @return list of selected files
 */
public List<File> getSelectedFiles(){
  final Object[] selectedValues=getSelectedValues();
  final List<File> selectedFiles=new ArrayList<File>(selectedValues.length);
  for (  Object value : selectedValues) {
    selectedFiles.add(((FileElement)value).getFile());
  }
  return selectedFiles;
}

Fixed version (ground truth):
/** 
 * Returns list of selected files.
 * @return list of selected files
 */
public List<File> getSelectedFiles(){
  final Object[] selectedValues=getSelectedValues();
  final List<File> selectedFiles=new ArrayList<File>(selectedValues.length);
  for (  final Object value : selectedValues) {
    selectedFiles.add(((FileElement)value).getFile());
  }
  return selectedFiles;
}
Program: 52609
Project: 52609
Buggy source:
/** 
 * Returns new scroll pane with fixed preferred size that fits file list settings.
 * @return new scroll pane with fixed preferred size that fits file list settings
 */
public WebScrollPane createScrollView(){
  return new WebScrollPane(WebFileList.this){
    @Override public Dimension getPreferredSize(){
      final Dimension ps=super.getPreferredSize();
      final Dimension oneCell;
      if (getModel().getSize() > 0) {
        oneCell=getCellBounds(0,0).getSize();
      }
 else {
        final WebFileListCellRenderer fileListCellRenderer=getWebFileListCellRenderer();
        if (fileListCellRenderer != null) {
          oneCell=fileListCellRenderer.getPreferredSize();
        }
 else {
          oneCell=new Dimension(400,300);
        }
      }
      final Insets bi=getInsets();
      ps.width=oneCell.width * preferredColumnCount + bi.left + bi.right + WebScrollBarUI.LENGTH + 1;
      ps.height=oneCell.height * preferredRowCount + bi.top + bi.bottom + 1;
      return ps;
    }
  }
;
}

Fixed version (ground truth):
/** 
 * Returns new scroll pane with fixed preferred size that fits file list settings.
 * @return new scroll pane with fixed preferred size that fits file list settings
 */
public WebScrollPane createScrollView(){
  return new WebScrollPane(WebFileList.this){
    @Override public Dimension getPreferredSize(){
      final Dimension ps=super.getPreferredSize();
      final int fcw=getFixedCellWidth();
      final int fch=getFixedCellHeight();
      final Dimension oneCell;
      if (fcw != -1 && fch != -1) {
        oneCell=new Dimension(fcw,fch);
      }
 else {
        if (getModel().getSize() > 0) {
          oneCell=getCellBounds(0,0).getSize();
        }
 else {
          final WebFileListCellRenderer fileListCellRenderer=getWebFileListCellRenderer();
          if (fileListCellRenderer != null) {
            oneCell=fileListCellRenderer.getPreferredSize();
          }
 else {
            oneCell=new Dimension(90,90);
          }
        }
        if (fcw != -1) {
          oneCell.width=fcw;
        }
 else         if (fch != -1) {
          oneCell.width=fcw;
        }
      }
      final Insets bi=getInsets();
      ps.width=oneCell.width * preferredColumnCount + bi.left + bi.right + WebScrollBarUI.LENGTH + 1;
      ps.height=oneCell.height * preferredRowCount + bi.top + bi.bottom + 1;
      return ps;
    }
  }
;
}
Program: 52610
Project: 52610
Buggy source:
/** 
 * Selects specified files if they present in the list.
 * @param files files to select
 */
public void setSelectedFiles(final Collection<File> files){
  final List<FileElement> elements=new ArrayList<FileElement>(files.size());
  for (  File file : files) {
    final FileElement element=getFileListModel().getElement(file);
    if (element != null) {
      elements.add(element);
    }
  }
  setSelectedValues(elements);
}

Fixed version (ground truth):
/** 
 * Selects specified files if they present in the list.
 * @param files files to select
 */
public void setSelectedFiles(final Collection<File> files){
  final List<FileElement> elements=new ArrayList<FileElement>(files.size());
  for (  final File file : files) {
    final FileElement element=getFileListModel().getElement(file);
    if (element != null) {
      elements.add(element);
    }
  }
  setSelectedValues(elements);
}
Program: 52611
Project: 52611
Buggy source:
/** 
 * Informs model that childs were loaded successfully.
 * @param childs list of loaded childs
 */
public void childsLoadCompleted(final List<E> childs);

Fixed version (ground truth):
/** 
 * Informs model that childs were loaded successfully.
 * @param childs list of loaded childs
 */
public void childsLoadCompleted(List<E> childs);
Program: 52612
Project: 52612
Buggy source:
/** 
 * Informs model that childs load failed due to the specified exception.
 * @param cause exception
 */
public void childsLoadFailed(final Throwable cause);

Fixed version (ground truth):
/** 
 * Informs model that childs load failed due to the specified exception.
 * @param cause exception
 */
public void childsLoadFailed(Throwable cause);
Program: 52614
Project: 52614
Buggy source:
/** 
 * Sets whether should display hidden files or not.
 * @param showHiddenFiles whether should display hidden files or not
 */
public void setShowHiddenFiles(boolean showHiddenFiles){
  this.showHiddenFiles=showHiddenFiles;
  updateDirectoryComponentFilters();
  updateFileComponentFilters();
}

Fixed version (ground truth):
/** 
 * Sets whether should display hidden files or not.
 * @param showHiddenFiles whether should display hidden files or not
 */
public void setShowHiddenFiles(final boolean showHiddenFiles){
  this.showHiddenFiles=showHiddenFiles;
  updateDirectoryComponentFilters();
  updateFileComponentFilters();
}
Program: 52615
Project: 52615
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public boolean accept(File file){
  return showHiddenFiles || !file.isHidden();
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean accept(final File file){
  return showHiddenFiles || !file.isHidden();
}
Program: 52617
Project: 52617
Buggy source:
@Override public Dimension getPreferredSize(){
  Dimension ps=super.getPreferredSize();
  ps.width=ps.width + WebScrollBarUI.LENGTH;
  ps.height=Math.min(ps.height,100);
  return ps;
}

Fixed version (ground truth):
@Override public Dimension getPreferredSize(){
  final Dimension ps=super.getPreferredSize();
  ps.width=ps.width + WebScrollBarUI.LENGTH;
  ps.height=Math.min(ps.height,100);
  return ps;
}
Program: 52618
Project: 52618
Buggy source:
/** 
 * Delete all selected in view files.
 */
public void deleteSelectedFiles(){
  final List<File> files=getAllSelectedFiles();
  if (files.isEmpty()) {
    return;
  }
  final WebPanel all=new WebPanel(new BorderLayout(0,5));
  all.add(new WebLabel(LanguageManager.get("String_Node_Str")),BorderLayout.NORTH);
  final WebPanel deleteFilesPanel=new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP,0,5,true,false));
  deleteFilesPanel.setMargin(3);
  deleteFilesPanel.setBackground(Color.WHITE);
  for (  File file : files) {
    deleteFilesPanel.add(new WebLabel(file.getName(),FileUtils.getFileIcon(file),WebLabel.LEFT));
  }
  final WebScrollPane scroll=new WebScrollPane(deleteFilesPanel){
    @Override public Dimension getPreferredSize(){
      Dimension ps=super.getPreferredSize();
      ps.width=ps.width + WebScrollBarUI.LENGTH;
      ps.height=Math.min(ps.height,100);
      return ps;
    }
  }
;
  all.add(scroll,BorderLayout.CENTER);
  final String title=LanguageManager.get("String_Node_Str");
  final int confirm=WebOptionPane.showConfirmDialog(WebFileChooserPanel.this,all,title,WebOptionPane.YES_NO_OPTION,WebOptionPane.QUESTION_MESSAGE);
  if (confirm == WebOptionPane.YES_OPTION) {
    FileUtils.deleteFiles(files);
    reloadCurrentFolder();
  }
}

Fixed version (ground truth):
/** 
 * Delete all selected in view files.
 */
public void deleteSelectedFiles(){
  final List<File> files=getAllSelectedFiles();
  if (files.isEmpty()) {
    return;
  }
  final WebPanel all=new WebPanel(new BorderLayout(0,5));
  all.add(new WebLabel(LanguageManager.get("String_Node_Str")),BorderLayout.NORTH);
  final WebPanel deleteFilesPanel=new WebPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP,0,5,true,false));
  deleteFilesPanel.setMargin(3);
  deleteFilesPanel.setBackground(Color.WHITE);
  for (  final File file : files) {
    deleteFilesPanel.add(new WebLabel(file.getName(),FileUtils.getFileIcon(file),WebLabel.LEFT));
  }
  final WebScrollPane scroll=new WebScrollPane(deleteFilesPanel){
    @Override public Dimension getPreferredSize(){
      final Dimension ps=super.getPreferredSize();
      ps.width=ps.width + WebScrollBarUI.LENGTH;
      ps.height=Math.min(ps.height,100);
      return ps;
    }
  }
;
  all.add(scroll,BorderLayout.CENTER);
  final String title=LanguageManager.get("String_Node_Str");
  final int confirm=WebOptionPane.showConfirmDialog(WebFileChooserPanel.this,all,title,WebOptionPane.YES_NO_OPTION,WebOptionPane.QUESTION_MESSAGE);
  if (confirm == WebOptionPane.YES_OPTION) {
    FileUtils.deleteFiles(files);
    reloadCurrentFolder();
  }
}
Program: 52619
Project: 52619
Buggy source:
/** 
 * Replaces the element at the specified position in this list with the specified element. <p/> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index   index of element to replace
 * @param element element to be stored at the specified position
 * @return the element previously at the specified position
 */
@Override public CheckBoxCellData set(int index,Object element){
  return (CheckBoxCellData)super.set(index,element);
}

Fixed version (ground truth):
/** 
 * Replaces the element at the specified position in this list with the specified element. <p> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index   index of element to replace
 * @param element element to be stored at the specified position
 * @return the element previously at the specified position
 */
@Override public CheckBoxCellData set(int index,Object element){
  return (CheckBoxCellData)super.set(index,element);
}
Program: 52620
Project: 52620
Buggy source:
/** 
 * Removes the element at the specified position in this list. Returns the element that was removed from the list. <p/> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index the index of the element to removed
 */
@Override public CheckBoxCellData remove(int index){
  return (CheckBoxCellData)super.remove(index);
}

Fixed version (ground truth):
/** 
 * Removes the element at the specified position in this list. Returns the element that was removed from the list. <p> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index the index of the element to removed
 */
@Override public CheckBoxCellData remove(int index){
  return (CheckBoxCellData)super.remove(index);
}
Program: 52621
Project: 52621
Buggy source:
/** 
 * Returns the element at the specified position in this list. <p/> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index index of element to return
 */
@Override public CheckBoxCellData get(int index){
  return (CheckBoxCellData)super.get(index);
}

Fixed version (ground truth):
/** 
 * Returns the element at the specified position in this list. <p> Throws an <code>ArrayIndexOutOfBoundsException</code> if the index is out of range (<code>index &lt; 0 || index &gt;= size()</code>).
 * @param index index of element to return
 */
@Override public CheckBoxCellData get(int index){
  return (CheckBoxCellData)super.get(index);
}
Program: 52622
Project: 52622
Buggy source:
/** 
 * Returns asynchronous tree root node. <p/> This request uses the EDT and should be processed quickly.
 * @return root node
 */
public E getRoot();

Fixed version (ground truth):
/** 
 * Returns asynchronous tree root node. <p> This request uses the EDT and should be processed quickly.
 * @return root node
 */
public E getRoot();
Program: 52623
Project: 52623
Buggy source:
/** 
 * Returns child nodes for the specified asynchronous tree node. <p/> This request uses a separate thread and might take a lot of time to process.
 * @param node parent node
 * @return list of child nodes
 */
public List<E> getChilds(E node);

Fixed version (ground truth):
/** 
 * Returns child nodes for the specified asynchronous tree node. <p> This request uses a separate thread and might take a lot of time to process.
 * @param node parent node
 * @return list of child nodes
 */
public List<E> getChilds(E node);
Program: 52624
Project: 52624
Buggy source:
/** 
 * Returns whether the specified node is leaf (doesn't have any childs) or not. <p/> This request uses the EDT and should be processed quickly. If you cannot be sure if the node is leaf or not - simply return false - this will allow the tree to expand this node on request.
 * @param node node
 * @return true if the specified node is leaf, false otherwise
 */
public boolean isLeaf(E node);

Fixed version (ground truth):
/** 
 * Returns whether the specified node is leaf (doesn't have any childs) or not. <p> This request uses the EDT and should be processed quickly. If you cannot be sure if the node is leaf or not - simply return false - this will allow the tree to expand this node on request.
 * @param node node
 * @return true if the specified node is leaf, false otherwise
 */
public boolean isLeaf(E node);
Program: 52625
Project: 52625
Buggy source:
/** 
 * Expands all visible tree rows in a single call. <p/> This method provides similar functionality to WebTree expandAll method and will actually expand all tree elements - even those which are not yet loaded from data provider. Make sure you know what you are doing before calling this method.
 */
@Override public final void expandAll(){
  for (int i=getRowCount() - 1; i >= 0; i--) {
    final TreePath path=getPathForRow(i);
    if (!getModel().isLeaf(getNodeForPath(path))) {
      performPathExpand(path);
    }
  }
}

Fixed version (ground truth):
/** 
 * Expands all visible tree rows in a single call. <p> This method provides similar functionality to WebTree expandAll method and will actually expand all tree elements - even those which are not yet loaded from data provider. Make sure you know what you are doing before calling this method.
 */
@Override public final void expandAll(){
  for (int i=getRowCount() - 1; i >= 0; i--) {
    final TreePath path=getPathForRow(i);
    if (!getModel().isLeaf(getNodeForPath(path))) {
      performPathExpand(path);
    }
  }
}
Program: 52626
Project: 52626
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent intent){
  if (resultCode == RESULT_OK && intent != null && intent.getData() != null) {
    Intent displayIntent=new Intent(this,TaskListActivity.class);
    displayIntent.putExtra(TaskListActivity.EXTRA_DISPLAY_TASK,true);
    displayIntent.putExtra(TaskListActivity.EXTRA_FORCE_LIST_SELECTION,true);
    Uri newTaskUri=intent.getData();
    displayIntent.setData(newTaskUri);
    onNewIntent(displayIntent);
  }
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent intent){
  if (resultCode == RESULT_OK && intent != null && intent.getData() != null) {
    Intent displayIntent=new Intent(this,TaskListActivity.class);
    displayIntent.putExtra(TaskListActivity.EXTRA_DISPLAY_TASK,true);
    displayIntent.putExtra(TaskListActivity.EXTRA_FORCE_LIST_SELECTION,true);
    Uri newTaskUri=intent.getData();
    displayIntent.setData(newTaskUri);
    onNewIntent(displayIntent);
    setupTabIcons();
  }
}
Program: 52628
Project: 52628
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
  int itemId=item.getItemId();
  if (itemId == R.id.edit_task) {
    mCallback.onEditTask(mTaskUri,mContentSet);
    return true;
  }
 else   if (itemId == R.id.delete_task) {
    new AlertDialog.Builder(getActivity()).setTitle(R.string.confirm_delete_title).setCancelable(true).setNegativeButton(android.R.string.cancel,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
      }
    }
).setPositiveButton(android.R.string.ok,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        if (mContentSet != null) {
          mContentSet.delete(mAppContext);
          mCallback.onDelete(mTaskUri);
        }
      }
    }
).setMessage(R.string.confirm_delete_message).create().show();
    return true;
  }
 else   if (itemId == R.id.complete_task) {
    completeTask();
    return true;
  }
 else   if (itemId == R.id.pin_task) {
    if (TaskFieldAdapters.PINNED.get(mContentSet)) {
      item.setIcon(R.drawable.ic_pin_white_24dp);
      TaskNotificationHandler.unpinTask(mAppContext,mContentSet);
    }
 else {
      item.setIcon(R.drawable.ic_pin_off_white_24dp);
      TaskNotificationHandler.pinTask(mAppContext,mContentSet);
    }
    persistTask();
    return true;
  }
 else   if (itemId == R.id.opentasks_send_task) {
    setSendMenuIntent();
    return false;
  }
 else {
    return super.onOptionsItemSelected(item);
  }
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
  mDetailView.updateValues();
  int itemId=item.getItemId();
  if (itemId == R.id.edit_task) {
    mCallback.onEditTask(mTaskUri,mContentSet);
    return true;
  }
 else   if (itemId == R.id.delete_task) {
    new AlertDialog.Builder(getActivity()).setTitle(R.string.confirm_delete_title).setCancelable(true).setNegativeButton(android.R.string.cancel,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
      }
    }
).setPositiveButton(android.R.string.ok,new OnClickListener(){
      @Override public void onClick(      DialogInterface dialog,      int which){
        if (mContentSet != null) {
          mContentSet.delete(mAppContext);
          mCallback.onDelete(mTaskUri);
        }
      }
    }
).setMessage(R.string.confirm_delete_message).create().show();
    return true;
  }
 else   if (itemId == R.id.complete_task) {
    completeTask();
    return true;
  }
 else   if (itemId == R.id.pin_task) {
    if (TaskFieldAdapters.PINNED.get(mContentSet)) {
      item.setIcon(R.drawable.ic_pin_white_24dp);
      TaskNotificationHandler.unpinTask(mAppContext,mContentSet);
    }
 else {
      item.setIcon(R.drawable.ic_pin_off_white_24dp);
      TaskNotificationHandler.pinTask(mAppContext,mContentSet);
    }
    persistTask();
    return true;
  }
 else   if (itemId == R.id.opentasks_send_task) {
    setSendMenuIntent();
    return false;
  }
 else {
    return super.onOptionsItemSelected(item);
  }
}
Program: 52629
Project: 52629
Buggy source:
@Override public void onFocusChange(View v,boolean hasFocus){
  itemView.findViewById(R.id.drag_handle).setVisibility(hasFocus ? View.INVISIBLE : View.VISIBLE);
  itemView.findViewById(R.id.remove_item).setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
}

Fixed version (ground truth):
@Override public void onFocusChange(View v,boolean hasFocus){
  itemView.findViewById(R.id.drag_handle).setVisibility(hasFocus ? View.INVISIBLE : View.VISIBLE);
  itemView.findViewById(R.id.remove_item).setVisibility(hasFocus ? View.VISIBLE : View.INVISIBLE);
  String newText=text.getText().toString();
  if (!hasFocus && !newText.equals(item.text) && mValues != null && !mCurrentValue.equals(mAdapter.get(mValues))) {
    item.text=newText;
    mAdapter.validateAndSet(mValues,mCurrentValue);
  }
}
Program: 52630
Project: 52630
Buggy source:
@Override public void afterTextChanged(Editable s){
  String newText=s.toString();
  if (!newText.equals(item.text) && mValues != null) {
    item.text=newText;
    mAdapter.validateAndSet(mValues,mCurrentValue);
  }
}

Fixed version (ground truth):
@Override public void afterTextChanged(Editable s){
  item.text=s.toString();
}