Program: 93790
Project: 93790
Buggy source:
@Override public Class<?> loadClass(String className) throws ClassNotFoundException {
  if (packageNameToCertificateMap == null)   return null;
  if (hasBeenWipedOut)   return null;
  String packageName=className.substring(0,className.lastIndexOf('.'));
  String containerPath=packageNameToContainerPathMap.get(packageName);
  if (containerPath == null)   return null;
  X509Certificate verifiedCertificate;
  verifiedCertificate=importCertificateFromAppPrivateDir(packageName);
  if (verifiedCertificate == null) {
    boolean isCertificateDownloadSuccessful=downloadCertificateRemotelyViaHttps(packageName);
    if (isCertificateDownloadSuccessful) {
      verifiedCertificate=importCertificateFromAppPrivateDir(packageName);
    }
  }
  if (verifiedCertificate != null) {
    int extensionIndex=containerPath.lastIndexOf("String_Node_Str");
    String extension=containerPath.substring(extensionIndex);
    boolean signatureCheckIsSuccessful=false;
    if (extension.equals("String_Node_Str")) {
      try {
        Signature mSignature=Signature.getInstance(verifiedCertificate.getSigAlgName());
        FileInputStream containerFIS=null;
        BufferedInputStream containerBufIn=null;
        try {
          containerFIS=new FileInputStream(containerPath);
          containerBufIn=new BufferedInputStream(containerFIS);
          byte[] buffer=new byte[1024];
          int len;
          while (containerBufIn.available() != 0) {
            len=containerBufIn.read(buffer);
            mSignature.update(buffer,0,len);
          }
          ;
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
 finally {
          if (containerBufIn != null) {
            try {
              containerBufIn.close();
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
          }
        }
        mSignature.initVerify(verifiedCertificate);
        android.content.pm.Signature apkSignature=mPackageManager.getPackageArchiveInfo(containerPath,PackageManager.GET_SIGNATURES).signatures[0];
        signatureCheckIsSuccessful=mSignature.verify(apkSignature.toByteArray());
      }
 catch (      NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
catch (      InvalidKeyException e) {
        e.printStackTrace();
      }
catch (      SignatureException e) {
        e.printStackTrace();
      }
    }
 else {
      if (extension.equals("String_Node_Str")) {
        JarFile jarContainerToVerify=null;
        try {
          jarContainerToVerify=new JarFile(containerPath);
          verifyJARContainer(jarContainerToVerify,verifiedCertificate);
          signatureCheckIsSuccessful=true;
        }
 catch (        IOException e) {
          signatureCheckIsSuccessful=false;
        }
 finally {
          if (jarContainerToVerify != null)           try {
            jarContainerToVerify.close();
          }
 catch (          IOException e) {
            e.printStackTrace();
          }
        }
      }
    }
    if (signatureCheckIsSuccessful) {
      return super.loadClass(className);
    }
    File containerToRemove=new File(containerPath);
    containerToRemove.delete();
    packageNameToContainerPathMap.remove(packageName);
    return null;
  }
  return null;
}

Fixed version (ground truth):
@Override public Class<?> loadClass(String className) throws ClassNotFoundException {
  if (packageNameToCertificateMap == null)   return null;
  if (hasBeenWipedOut)   return null;
  String packageName=className.substring(0,className.lastIndexOf('.'));
  String containerPath=packageNameToContainerPathMap.get(packageName);
  if (containerPath == null)   return null;
  X509Certificate verifiedCertificate;
  verifiedCertificate=importCertificateFromAppPrivateDir(packageName);
  if (verifiedCertificate == null) {
    boolean isCertificateDownloadSuccessful=downloadCertificateRemotelyViaHttps(packageName);
    if (isCertificateDownloadSuccessful) {
      verifiedCertificate=importCertificateFromAppPrivateDir(packageName);
    }
  }
  if (verifiedCertificate != null) {
    int extensionIndex=containerPath.lastIndexOf("String_Node_Str");
    String extension=containerPath.substring(extensionIndex);
    boolean signatureCheckIsSuccessful=false;
    if (extension.equals("String_Node_Str")) {
      try {
        Signature mSignature=Signature.getInstance(verifiedCertificate.getSigAlgName());
        mSignature.initVerify(verifiedCertificate);
        FileInputStream containerFIS=null;
        BufferedInputStream containerBufIn=null;
        try {
          containerFIS=new FileInputStream(containerPath);
          containerBufIn=new BufferedInputStream(containerFIS);
          byte[] buffer=new byte[1024];
          int len;
          while (containerBufIn.available() != 0) {
            len=containerBufIn.read(buffer);
            mSignature.update(buffer,0,len);
          }
          ;
        }
 catch (        IOException e) {
          e.printStackTrace();
        }
 finally {
          if (containerBufIn != null) {
            try {
              containerBufIn.close();
            }
 catch (            IOException e) {
              e.printStackTrace();
            }
          }
        }
        android.content.pm.Signature apkSignature=mPackageManager.getPackageArchiveInfo(containerPath,PackageManager.GET_SIGNATURES).signatures[0];
        signatureCheckIsSuccessful=mSignature.verify(apkSignature.toByteArray());
      }
 catch (      NoSuchAlgorithmException e) {
        e.printStackTrace();
      }
catch (      InvalidKeyException e) {
        e.printStackTrace();
      }
catch (      SignatureException e) {
        e.printStackTrace();
      }
    }
 else {
      if (extension.equals("String_Node_Str")) {
        JarFile jarContainerToVerify=null;
        try {
          jarContainerToVerify=new JarFile(containerPath);
          verifyJARContainer(jarContainerToVerify,verifiedCertificate);
          signatureCheckIsSuccessful=true;
        }
 catch (        IOException e) {
          signatureCheckIsSuccessful=false;
        }
 finally {
          if (jarContainerToVerify != null)           try {
            jarContainerToVerify.close();
          }
 catch (          IOException e) {
            e.printStackTrace();
          }
        }
      }
    }
    if (signatureCheckIsSuccessful) {
      return super.loadClass(className);
    }
    File containerToRemove=new File(containerPath);
    containerToRemove.delete();
    packageNameToContainerPathMap.remove(packageName);
    return null;
  }
  return null;
}