Program: 37537
Project: 37537
Buggy source:
/** 
 * 有大小限制的加载图片
 * @param context
 * @param path
 * @param width   最大宽度
 * @param height  最大高度
 * @return
 */
public static Bitmap loadBitmap(Context context,String path,int width,int height){
  InputStream in=null;
  try {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    if (Path.ASSETS.belongsTo(path)) {
      in=context.getAssets().open(Path.ASSETS.crop(path));
      if (in != null) {
        BitmapFactory.decodeStream(in,null,options);
      }
    }
 else     if (Path.FILE.belongsTo(path)) {
      BitmapFactory.decodeFile(Path.FILE.crop(path),options);
    }
 else     if (Path.DRAWABLE.belongsTo(path)) {
      BitmapFactory.decodeResource(context.getResources(),Integer.parseInt(Path.DRAWABLE.crop(path)),options);
    }
 else {
      BitmapFactory.decodeFile(path,options);
    }
    int outWidth=options.outWidth;
    int outHeight=options.outHeight;
    int sampleSize=1;
    while (outWidth / sampleSize > width || outHeight / sampleSize > height) {
      sampleSize++;
    }
    options.inJustDecodeBounds=false;
    options.inSampleSize=sampleSize;
    if (Path.ASSETS.belongsTo(path)) {
      in=context.getAssets().open(Path.ASSETS.crop(path));
      if (in != null) {
        return BitmapFactory.decodeStream(in,null,options);
      }
    }
 else     if (Path.FILE.belongsTo(path)) {
      return BitmapFactory.decodeFile(Path.FILE.crop(path),options);
    }
 else     if (Path.DRAWABLE.belongsTo(path)) {
      return BitmapFactory.decodeResource(context.getResources(),Integer.parseInt(Path.DRAWABLE.crop(path)),options);
    }
 else {
      return BitmapFactory.decodeFile(path,options);
    }
  }
 catch (  IOException|OutOfMemoryError e) {
    e.printStackTrace();
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * 有大小限制的加载图片
 * @param context
 * @param path
 * @param width   最大宽度
 * @param height  最大高度
 * @return
 */
public static Bitmap loadBitmap(Context context,String path,int width,int height){
  InputStream in=null;
  try {
    BitmapFactory.Options options=new BitmapFactory.Options();
    options.inJustDecodeBounds=true;
    if (Path.ASSETS.belongsTo(path)) {
      in=context.getAssets().open(Path.ASSETS.crop(path));
      if (in != null) {
        BitmapFactory.decodeStream(in,null,options);
      }
    }
 else     if (Path.FILE.belongsTo(path)) {
      BitmapFactory.decodeFile(Path.FILE.crop(path),options);
    }
 else     if (Path.DRAWABLE.belongsTo(path)) {
      BitmapFactory.decodeResource(context.getResources(),Integer.parseInt(Path.DRAWABLE.crop(path)),options);
    }
 else {
      BitmapFactory.decodeFile(path,options);
    }
    int outWidth=options.outWidth;
    int outHeight=options.outHeight;
    int sampleSize=1;
    while (outWidth / (sampleSize * 2) > width || outHeight / (sampleSize * 2) > height) {
      sampleSize*=2;
    }
    options.inJustDecodeBounds=false;
    options.inSampleSize=sampleSize;
    if (Path.ASSETS.belongsTo(path)) {
      in=context.getAssets().open(Path.ASSETS.crop(path));
      if (in != null) {
        return BitmapFactory.decodeStream(in,null,options);
      }
    }
 else     if (Path.FILE.belongsTo(path)) {
      return BitmapFactory.decodeFile(Path.FILE.crop(path),options);
    }
 else     if (Path.DRAWABLE.belongsTo(path)) {
      return BitmapFactory.decodeResource(context.getResources(),Integer.parseInt(Path.DRAWABLE.crop(path)),options);
    }
 else {
      return BitmapFactory.decodeFile(path,options);
    }
  }
 catch (  IOException|OutOfMemoryError e) {
    e.printStackTrace();
  }
 finally {
    if (in != null) {
      try {
        in.close();
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
  return null;
}