nus-yam/ex-repair huggingface dataset:
Program: 38378
Project: 38378
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (getParameters() == null || mResources == null) {
    return bitmap;
  }
  int w=bitmap.getWidth();
  int h=bitmap.getHeight();
  if (mFxBitmap == null || mFxBitmapId != getParameters().getBitmapResource()) {
    BitmapFactory.Options o=new BitmapFactory.Options();
    o.inScaled=false;
    mFxBitmapId=getParameters().getBitmapResource();
    if (mFxBitmapId != 0) {
      mFxBitmap=BitmapFactory.decodeResource(mResources,mFxBitmapId,o);
    }
 else {
      Log.w(LOGTAG,"String_Node_Str" + mName);
    }
  }
  if (mFxBitmap == null) {
    return bitmap;
  }
  int fxw=mFxBitmap.getWidth();
  int fxh=mFxBitmap.getHeight();
  nativeApplyFilter(bitmap,w,h,mFxBitmap,fxw,fxh);
  return bitmap;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (getParameters() == null || mResources == null) {
    return bitmap;
  }
  int w=bitmap.getWidth();
  int h=bitmap.getHeight();
  int bitmapResourceId=getParameters().getBitmapResource();
  if (bitmapResourceId == 0) {
    return bitmap;
  }
  if (mFxBitmap == null || mFxBitmapId != bitmapResourceId) {
    BitmapFactory.Options o=new BitmapFactory.Options();
    o.inScaled=false;
    mFxBitmapId=bitmapResourceId;
    if (mFxBitmapId != 0) {
      mFxBitmap=BitmapFactory.decodeResource(mResources,mFxBitmapId,o);
    }
 else {
      Log.w(LOGTAG,"String_Node_Str" + mName);
    }
  }
  if (mFxBitmap == null) {
    return bitmap;
  }
  int fxw=mFxBitmap.getWidth();
  int fxh=mFxBitmap.getHeight();
  nativeApplyFilter(bitmap,w,h,mFxBitmap,fxw,fxh);
  return bitmap;
}
Program: 38379
Project: 38379
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (bitmap == null || bitmap.getWidth() == 0 || bitmap.getHeight() == 0) {
    return bitmap;
  }
  try {
synchronized (ImageFilterRS.class) {
      if (sRS == null) {
        Log.w(LOGTAG,"String_Node_Str");
        return bitmap;
      }
      CachingPipeline pipeline=getEnvironment().getCachingPipeline();
      boolean needsUpdate=pipeline.prepareRenderscriptAllocations(bitmap);
      if (needsUpdate || !isResourcesLoaded()) {
        freeResources();
        createFilter(sResources,scaleFactor,quality);
        setResourcesLoaded(true);
      }
      runFilter();
      update(bitmap);
    }
  }
 catch (  android.renderscript.RSIllegalArgumentException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  android.renderscript.RSRuntimeException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  java.lang.OutOfMemoryError e) {
    System.gc();
    displayLowMemoryToast();
    Log.e(LOGTAG,"String_Node_Str" + getName(),e);
  }
  return bitmap;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (bitmap == null || bitmap.getWidth() == 0 || bitmap.getHeight() == 0) {
    return bitmap;
  }
  try {
synchronized (ImageFilterRS.class) {
      if (sRS == null) {
        Log.w(LOGTAG,"String_Node_Str");
        return bitmap;
      }
      CachingPipeline pipeline=getEnvironment().getCachingPipeline();
      if (DEBUG) {
        Log.v(LOGTAG,"String_Node_Str" + getName() + "String_Node_Str"+ pipeline.getName());
      }
      boolean needsUpdate=pipeline.prepareRenderscriptAllocations(bitmap);
      if (needsUpdate || !isResourcesLoaded()) {
        freeResources();
        createFilter(sResources,scaleFactor,quality);
        setResourcesLoaded(true);
      }
      runFilter();
      update(bitmap);
      if (DEBUG) {
        Log.v(LOGTAG,"String_Node_Str" + getName() + "String_Node_Str"+ pipeline.getName());
      }
    }
  }
 catch (  android.renderscript.RSIllegalArgumentException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  android.renderscript.RSRuntimeException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  java.lang.OutOfMemoryError e) {
    System.gc();
    displayLowMemoryToast();
    Log.e(LOGTAG,"String_Node_Str" + getName(),e);
  }
  return bitmap;
}
Program: 38380
Project: 38380
Buggy source:
/** 
 * The task should be executed with one given bitmap to be saved.
 */
@Override protected Uri doInBackground(ImagePreset... params){
  if (params[0] == null || sourceUri == null) {
    return null;
  }
  ImagePreset preset=params[0];
  BitmapFactory.Options options=new BitmapFactory.Options();
  Uri uri=null;
  boolean noBitmap=true;
  int num_tries=0;
  while (noBitmap) {
    try {
      Bitmap bitmap=ImageLoader.loadMutableBitmap(context,sourceUri,options);
      if (bitmap == null) {
        return null;
      }
      preset.setupEnvironment();
      bitmap=preset.applyGeometry(bitmap);
      bitmap=preset.apply(bitmap);
      Object xmp=getPanoramaXMPData(sourceUri,preset);
      ExifInterface exif=getExifData(sourceUri);
      long time=System.currentTimeMillis();
      exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME,time,TimeZone.getDefault());
      exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,ExifInterface.Orientation.TOP_LEFT));
      if (putExifData(this.destinationFile,exif,bitmap)) {
        putPanoramaXMPData(this.destinationFile,xmp);
        uri=insertContent(context,sourceUri,this.destinationFile,saveFileName,time);
      }
      noBitmap=false;
    }
 catch (    java.lang.OutOfMemoryError e) {
      if (++num_tries >= 5) {
        throw e;
      }
      System.gc();
      options.inSampleSize*=2;
    }
  }
  return uri;
}

Fixed version (ground truth):
/** 
 * The task should be executed with one given bitmap to be saved.
 */
@Override protected Uri doInBackground(ImagePreset... params){
  if (params[0] == null || sourceUri == null) {
    return null;
  }
  ImagePreset preset=params[0];
  BitmapFactory.Options options=new BitmapFactory.Options();
  Uri uri=null;
  boolean noBitmap=true;
  int num_tries=0;
  while (noBitmap) {
    try {
      Bitmap bitmap=ImageLoader.loadMutableBitmap(context,sourceUri,options);
      if (bitmap == null) {
        return null;
      }
      CachingPipeline pipeline=new CachingPipeline(FiltersManager.getManager(),"String_Node_Str");
      bitmap=pipeline.renderFinalImage(bitmap,preset);
      Object xmp=getPanoramaXMPData(sourceUri,preset);
      ExifInterface exif=getExifData(sourceUri);
      long time=System.currentTimeMillis();
      exif.addDateTimeStampTag(ExifInterface.TAG_DATE_TIME,time,TimeZone.getDefault());
      exif.setTag(exif.buildTag(ExifInterface.TAG_ORIENTATION,ExifInterface.Orientation.TOP_LEFT));
      if (putExifData(this.destinationFile,exif,bitmap)) {
        putPanoramaXMPData(this.destinationFile,xmp);
        uri=insertContent(context,sourceUri,this.destinationFile,saveFileName,time);
      }
      noBitmap=false;
    }
 catch (    java.lang.OutOfMemoryError e) {
      if (++num_tries >= 5) {
        throw e;
      }
      System.gc();
      options.inSampleSize*=2;
    }
  }
  return uri;
}
Program: 38381
Project: 38381
Buggy source:
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  setDefaultValues();
  loadXML();
  if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    mShowingImageStatePanel=true;
  }
  if (mShowingHistoryPanel) {
    toggleHistoryPanel();
  }
  if (mShowingTinyPlanet == false) {
    View tinyPlanetView=findViewById(EditorTinyPlanet.ID);
    if (tinyPlanetView != null) {
      tinyPlanetView.setVisibility(View.GONE);
    }
  }
  final View loading=findViewById(R.id.loading);
  loading.setVisibility(View.GONE);
}

Fixed version (ground truth):
@Override public void onConfigurationChanged(Configuration newConfig){
  super.onConfigurationChanged(newConfig);
  setDefaultValues();
  loadXML();
  if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
    mShowingImageStatePanel=true;
  }
 else   if (mShowingImageStatePanel) {
    toggleImageStatePanel();
  }
  if (mShowingHistoryPanel) {
    toggleHistoryPanel();
  }
  if (mShowingTinyPlanet == false) {
    View tinyPlanetView=findViewById(EditorTinyPlanet.ID);
    if (tinyPlanetView != null) {
      tinyPlanetView.setVisibility(View.GONE);
    }
  }
  final View loading=findViewById(R.id.loading);
  loading.setVisibility(View.GONE);
}
Program: 38382
Project: 38382
Buggy source:
public void prepare(Bitmap bitmap,float scaleFactor,int quality){
  if (mOutPixelsAllocation == null || mInPixelsAllocation == null || bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight) {
    destroyPixelAllocations();
    Bitmap bitmapBuffer=bitmap;
    if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
      bitmapBuffer=bitmap.copy(BITMAP_CONFIG,true);
    }
    mOutPixelsAllocation=Allocation.createFromBitmap(sRS,bitmapBuffer,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
    mInPixelsAllocation=Allocation.createTyped(sRS,mOutPixelsAllocation.getType());
  }
  mInPixelsAllocation.copyFrom(bitmap);
  if (bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight || !isResourcesLoaded()) {
    freeResources();
    createFilter(sResources,scaleFactor,quality);
    sWidth=bitmap.getWidth();
    sHeight=bitmap.getHeight();
    setResourcesLoaded(true);
  }
}

Fixed version (ground truth):
protected void prepare(Bitmap bitmap,float scaleFactor,int quality){
  if (mOutPixelsAllocation == null || mInPixelsAllocation == null || bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight) {
    destroyPixelAllocations();
    Bitmap bitmapBuffer=bitmap;
    if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
      bitmapBuffer=bitmap.copy(BITMAP_CONFIG,true);
    }
    mOutPixelsAllocation=Allocation.createFromBitmap(sRS,bitmapBuffer,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
    mInPixelsAllocation=Allocation.createTyped(sRS,mOutPixelsAllocation.getType());
  }
  mInPixelsAllocation.copyFrom(bitmap);
  if (bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight || !isResourcesLoaded()) {
    freeResources();
    createFilter(sResources,scaleFactor,quality);
    sWidth=bitmap.getWidth();
    sHeight=bitmap.getHeight();
    setResourcesLoaded(true);
  }
}
Program: 38383
Project: 38383
Buggy source:
abstract public void createFilter(android.content.res.Resources res,float scaleFactor,int quality);

Fixed version (ground truth):
protected abstract void createFilter(android.content.res.Resources res,float scaleFactor,int quality);
Program: 38384
Project: 38384
Buggy source:
public void update(Bitmap bitmap){
  mOutPixelsAllocation.copyTo(bitmap);
}

Fixed version (ground truth):
protected void update(Bitmap bitmap){
  mOutPixelsAllocation.copyTo(bitmap);
}
Program: 38385
Project: 38385
Buggy source:
public void freeResources(){
  if (!isResourcesLoaded()) {
    return;
  }
  resetAllocations();
  setResourcesLoaded(false);
}

Fixed version (ground truth):
public void freeResources(){
  if (!isResourcesLoaded()) {
    return;
  }
synchronized (ImageFilterRS.class) {
    resetAllocations();
    setResourcesLoaded(false);
  }
}
Program: 38386
Project: 38386
Buggy source:
abstract public void runFilter();

Fixed version (ground truth):
protected abstract void runFilter();
Program: 38387
Project: 38387
Buggy source:
@Override public void createFilter(android.content.res.Resources res,float scaleFactor,int quality){
  int w=mInPixelsAllocation.getType().getX();
  int h=mInPixelsAllocation.getType().getY();
  mScaleFactor=scaleFactor;
  if (mScript == null) {
    mScript=new ScriptC_convolve3x3(getRenderScriptContext(),res,R.raw.convolve3x3);
  }
  mScript.set_gWidth(w);
  mScript.set_gHeight(h);
}

Fixed version (ground truth):
@Override protected void createFilter(android.content.res.Resources res,float scaleFactor,int quality){
  int w=mInPixelsAllocation.getType().getX();
  int h=mInPixelsAllocation.getType().getY();
  mScaleFactor=scaleFactor;
  if (mScript == null) {
    mScript=new ScriptC_convolve3x3(getRenderScriptContext(),res,R.raw.convolve3x3);
  }
  mScript.set_gWidth(w);
  mScript.set_gHeight(h);
}
Program: 38388
Project: 38388
Buggy source:
@Override public void runFilter(){
  if (mParameters == null) {
    return;
  }
  computeKernel();
  mScript.set_gIn(mInPixelsAllocation);
  mScript.bind_gPixels(mInPixelsAllocation);
  mScript.forEach_root(mInPixelsAllocation,mOutPixelsAllocation);
}

Fixed version (ground truth):
@Override protected void runFilter(){
  if (mParameters == null) {
    return;
  }
  computeKernel();
  mScript.set_gIn(mInPixelsAllocation);
  mScript.bind_gPixels(mInPixelsAllocation);
  mScript.forEach_root(mInPixelsAllocation,mOutPixelsAllocation);
}
Program: 38389
Project: 38389
Buggy source:
public static void reset(){
  sInstance=null;
}

Fixed version (ground truth):
public static void reset(){
  sInstance=null;
  sPreviewInstance=null;
}
Program: 38390
Project: 38390
Buggy source:
public void prepare(Bitmap bitmap,float scaleFactor,int quality){
  if (mOutPixelsAllocation == null || mInPixelsAllocation == null || bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight) {
    destroyPixelAllocations();
    Bitmap bitmapBuffer=bitmap;
    if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
      bitmapBuffer=bitmap.copy(BITMAP_CONFIG,true);
    }
    mOutPixelsAllocation=Allocation.createFromBitmap(sRS,bitmapBuffer,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
    mInPixelsAllocation=Allocation.createTyped(sRS,mOutPixelsAllocation.getType());
  }
  mInPixelsAllocation.copyFrom(bitmap);
  if (bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight || !isResourcesLoaded()) {
    freeResources();
    createFilter(sResources,scaleFactor,quality);
    sWidth=bitmap.getWidth();
    sHeight=bitmap.getHeight();
    setResourcesLoaded(true);
  }
}

Fixed version (ground truth):
protected void prepare(Bitmap bitmap,float scaleFactor,int quality){
  if (mOutPixelsAllocation == null || mInPixelsAllocation == null || bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight) {
    destroyPixelAllocations();
    Bitmap bitmapBuffer=bitmap;
    if (bitmap.getConfig() == null || bitmap.getConfig() != BITMAP_CONFIG) {
      bitmapBuffer=bitmap.copy(BITMAP_CONFIG,true);
    }
    mOutPixelsAllocation=Allocation.createFromBitmap(sRS,bitmapBuffer,Allocation.MipmapControl.MIPMAP_NONE,Allocation.USAGE_SCRIPT);
    mInPixelsAllocation=Allocation.createTyped(sRS,mOutPixelsAllocation.getType());
  }
  mInPixelsAllocation.copyFrom(bitmap);
  if (bitmap.getWidth() != sWidth || bitmap.getHeight() != sHeight || !isResourcesLoaded()) {
    freeResources();
    createFilter(sResources,scaleFactor,quality);
    sWidth=bitmap.getWidth();
    sHeight=bitmap.getHeight();
    setResourcesLoaded(true);
  }
}
Program: 38391
Project: 38391
Buggy source:
abstract public void createFilter(android.content.res.Resources res,float scaleFactor,int quality);

Fixed version (ground truth):
protected abstract void createFilter(android.content.res.Resources res,float scaleFactor,int quality);
Program: 38392
Project: 38392
Buggy source:
public void update(Bitmap bitmap){
  mOutPixelsAllocation.copyTo(bitmap);
}

Fixed version (ground truth):
protected void update(Bitmap bitmap){
  mOutPixelsAllocation.copyTo(bitmap);
}
Program: 38393
Project: 38393
Buggy source:
public void freeResources(){
  if (!isResourcesLoaded()) {
    return;
  }
  resetAllocations();
  setResourcesLoaded(false);
}

Fixed version (ground truth):
public void freeResources(){
  if (!isResourcesLoaded()) {
    return;
  }
synchronized (ImageFilterRS.class) {
    resetAllocations();
    setResourcesLoaded(false);
  }
}
Program: 38394
Project: 38394
Buggy source:
abstract public void runFilter();

Fixed version (ground truth):
protected abstract void runFilter();
Program: 38395
Project: 38395
Buggy source:
@Override public void createFilter(android.content.res.Resources res,float scaleFactor,int quality){
  int w=mInPixelsAllocation.getType().getX();
  int h=mInPixelsAllocation.getType().getY();
  mScaleFactor=scaleFactor;
  if (mScript == null) {
    mScript=new ScriptC_convolve3x3(getRenderScriptContext(),res,R.raw.convolve3x3);
  }
  mScript.set_gWidth(w);
  mScript.set_gHeight(h);
}

Fixed version (ground truth):
@Override protected void createFilter(android.content.res.Resources res,float scaleFactor,int quality){
  int w=mInPixelsAllocation.getType().getX();
  int h=mInPixelsAllocation.getType().getY();
  mScaleFactor=scaleFactor;
  if (mScript == null) {
    mScript=new ScriptC_convolve3x3(getRenderScriptContext(),res,R.raw.convolve3x3);
  }
  mScript.set_gWidth(w);
  mScript.set_gHeight(h);
}
Program: 38396
Project: 38396
Buggy source:
@Override public void runFilter(){
  if (mParameters == null) {
    return;
  }
  computeKernel();
  mScript.set_gIn(mInPixelsAllocation);
  mScript.bind_gPixels(mInPixelsAllocation);
  mScript.forEach_root(mInPixelsAllocation,mOutPixelsAllocation);
}

Fixed version (ground truth):
@Override protected void runFilter(){
  if (mParameters == null) {
    return;
  }
  computeKernel();
  mScript.set_gIn(mInPixelsAllocation);
  mScript.bind_gPixels(mInPixelsAllocation);
  mScript.forEach_root(mInPixelsAllocation,mOutPixelsAllocation);
}
Program: 38397
Project: 38397
Buggy source:
public static void reset(){
  sInstance=null;
}

Fixed version (ground truth):
public static void reset(){
  sInstance=null;
  sPreviewInstance=null;
}
Program: 38398
Project: 38398
Buggy source:
@TargetApi(16) public SelectionManager(Activity activity){
  mActivity=activity;
  if (ApiHelper.AT_LEAST_16) {
    mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity);
    mNfcAdapter.setBeamPushUrisCallback(this,mActivity);
  }
}

Fixed version (ground truth):
public SelectionManager(Activity activity){
  mActivity=activity;
  if (ApiHelper.AT_LEAST_16) {
    mNfcAdapter=NfcAdapter.getDefaultAdapter(mActivity);
    mNfcAdapter.setBeamPushUrisCallback(new CreateBeamUrisCallback(){
      @Override public Uri[] createBeamUris(      NfcEvent arg0){
        if (mCachedShareableUris == null)         return null;
        return mCachedShareableUris.toArray(new Uri[mCachedShareableUris.size()]);
      }
    }
,mActivity);
  }
}
Program: 38399
Project: 38399
Buggy source:
@Override public Uri[] createBeamUris(NfcEvent event){
  if (mCachedShareableUris == null)   return null;
  return mCachedShareableUris.toArray(new Uri[mCachedShareableUris.size()]);
}

Fixed version (ground truth):
@Override public Uri[] createBeamUris(NfcEvent arg0){
  if (mCachedShareableUris == null)   return null;
  return mCachedShareableUris.toArray(new Uri[mCachedShareableUris.size()]);
}
Program: 38400
Project: 38400
Buggy source:
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  View view=mInflater.inflate(R.layout.photo_set_item,parent,false);
  LayoutParams params=view.getLayoutParams();
  int columnWidth=((GridView)parent).getColumnWidth();
  params.height=columnWidth;
  view.setLayoutParams(params);
  return view;
}

Fixed version (ground truth):
@Override public View newView(Context context,Cursor cursor,ViewGroup parent){
  View view=mInflater.inflate(R.layout.photo_set_item,parent,false);
  return view;
}
Program: 38403
Project: 38403
Buggy source:
public void setupMasterImage(){
  mImageLoader=new ImageLoader(this,getApplicationContext());
  HistoryAdapter mHistoryAdapter=new HistoryAdapter(this,R.layout.filtershow_history_operation_row,R.id.rowTextView);
  ImageStateAdapter mImageStateAdapter=new ImageStateAdapter(this,R.layout.filtershow_imagestate_row);
  MasterImage.reset();
  mMasterImage=MasterImage.getImage();
  mMasterImage.setHistoryAdapter(mHistoryAdapter);
  mMasterImage.setStateAdapter(mImageStateAdapter);
  mMasterImage.setActivity(this);
}

Fixed version (ground truth):
public void setupMasterImage(){
  mImageLoader=new ImageLoader(this,getApplicationContext());
  HistoryAdapter mHistoryAdapter=new HistoryAdapter(this,R.layout.filtershow_history_operation_row,R.id.rowTextView);
  ImageStateAdapter mImageStateAdapter=new ImageStateAdapter(this,R.layout.filtershow_imagestate_row);
  MasterImage.reset();
  mMasterImage=MasterImage.getImage();
  mMasterImage.setHistoryAdapter(mHistoryAdapter);
  mMasterImage.setStateAdapter(mImageStateAdapter);
  mMasterImage.setActivity(this);
  mMasterImage.setImageLoader(mImageLoader);
}
Program: 38404
Project: 38404
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  View view=convertView;
  if (view == null) {
    LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view=inflater.inflate(R.layout.filtershow_history_operation_row,null);
  }
  ImagePreset item=getItem(position);
  if (item != null) {
    TextView itemView=(TextView)view.findViewById(R.id.rowTextView);
    if (itemView != null) {
      itemView.setText(item.historyName());
    }
    ImageView preview=(ImageView)view.findViewById(R.id.preview);
    Bitmap bmp=item.getPreviewImage();
    if (bmp != null) {
      preview.setImageBitmap(bmp);
    }
    if (position == mCurrentPresetPosition) {
      view.setBackgroundColor(Color.WHITE);
    }
 else {
      view.setBackgroundResource(R.color.background_main_toolbar);
    }
  }
  return view;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  View view=convertView;
  if (view == null) {
    LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view=inflater.inflate(R.layout.filtershow_history_operation_row,null);
  }
  ImagePreset item=getItem(position);
  if (item != null) {
    TextView itemView=(TextView)view.findViewById(R.id.rowTextView);
    if (itemView != null) {
      itemView.setText(item.historyName());
    }
    ImageView preview=(ImageView)view.findViewById(R.id.preview);
    Bitmap bmp=item.getPreviewImage();
    if (bmp != null) {
      preview.setImageBitmap(bmp);
    }
 else {
      preview.setImageResource(android.R.color.transparent);
    }
    if (position == mCurrentPresetPosition) {
      view.setBackgroundColor(Color.WHITE);
    }
 else {
      view.setBackgroundResource(R.color.background_main_toolbar);
    }
  }
  return view;
}
Program: 38405
Project: 38405
Buggy source:
public void useFilterRepresentation(FilterRepresentation filterRepresentation){
  if (filterRepresentation == null) {
    return;
  }
  if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
    return;
  }
  ImagePreset oldPreset=MasterImage.getImage().getPreset();
  ImagePreset copy=new ImagePreset(oldPreset);
  FilterRepresentation representation=copy.getRepresentation(filterRepresentation);
  if (representation == null) {
    copy.addFilter(filterRepresentation);
  }
 else {
    if (filterRepresentation.allowsMultipleInstances()) {
      representation.updateTempParametersFrom(filterRepresentation);
      copy.setHistoryName(filterRepresentation.getName());
    }
    filterRepresentation=representation;
  }
  MasterImage.getImage().setPreset(copy,true);
  MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}

Fixed version (ground truth):
public void useFilterRepresentation(FilterRepresentation filterRepresentation){
  if (filterRepresentation == null) {
    return;
  }
  if (MasterImage.getImage().getCurrentFilterRepresentation() == filterRepresentation) {
    return;
  }
  ImagePreset oldPreset=MasterImage.getImage().getPreset();
  ImagePreset copy=new ImagePreset(oldPreset);
  FilterRepresentation representation=copy.getRepresentation(filterRepresentation);
  if (representation == null) {
    copy.addFilter(filterRepresentation);
  }
 else {
    if (filterRepresentation.allowsMultipleInstances()) {
      representation.updateTempParametersFrom(filterRepresentation);
      copy.setHistoryName(filterRepresentation.getName());
      representation.synchronizeRepresentation();
    }
    filterRepresentation=representation;
  }
  MasterImage.getImage().setPreset(copy,true);
  MasterImage.getImage().setCurrentFilterRepresentation(filterRepresentation);
}
Program: 38406
Project: 38406
Buggy source:
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterFxRepresentation representation=(FilterFxRepresentation)super.clone();
  representation.setName(getName());
  representation.setBitmapResource(getBitmapResource());
  representation.setNameResource(getNameResource());
  representation.setFxBitmap(getFxBitmap());
  return representation;
}

Fixed version (ground truth):
@Override public synchronized FilterRepresentation clone() throws CloneNotSupportedException {
  FilterFxRepresentation representation=(FilterFxRepresentation)super.clone();
  representation.setName(getName());
  representation.setBitmapResource(getBitmapResource());
  representation.setNameResource(getNameResource());
  return representation;
}
Program: 38407
Project: 38407
Buggy source:
public void useParametersFrom(FilterRepresentation a){
  if (a instanceof FilterFxRepresentation) {
    FilterFxRepresentation representation=(FilterFxRepresentation)a;
    setName(representation.getName());
    setBitmapResource(representation.getBitmapResource());
    setNameResource(representation.getNameResource());
    setFxBitmap(representation.getFxBitmap());
  }
}

Fixed version (ground truth):
public synchronized void useParametersFrom(FilterRepresentation a){
  if (a instanceof FilterFxRepresentation) {
    FilterFxRepresentation representation=(FilterFxRepresentation)a;
    setName(representation.getName());
    setBitmapResource(representation.getBitmapResource());
    setNameResource(representation.getNameResource());
  }
}
Program: 38408
Project: 38408
Buggy source:
public String toString(){
  return "String_Node_Str" + getName();
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + hashCode() + "String_Node_Str"+ getName()+ "String_Node_Str"+ mBitmapResource;
}
Program: 38409
Project: 38409
Buggy source:
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterRepresentation representation=(FilterRepresentation)super.clone();
  representation.setName(getName());
  representation.setPriority(getPriority());
  representation.setFilterClass(getFilterClass());
  representation.setSupportsPartialRendering(supportsPartialRendering());
  representation.setTextId(getTextId());
  representation.setEditorId(getEditorId());
  representation.setButtonId(getButtonId());
  representation.setOverlayId(getOverlayId());
  representation.setOverlayOnly(getOverlayOnly());
  representation.setShowEditingControls(showEditingControls());
  representation.setShowParameterValue(showParameterValue());
  representation.setShowUtilityPanel(showUtilityPanel());
  Log.v(LOGTAG,"String_Node_Str" + this + "String_Node_Str"+ representation+ "String_Node_Str");
  return representation;
}

Fixed version (ground truth):
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterRepresentation representation=(FilterRepresentation)super.clone();
  representation.setName(getName());
  representation.setPriority(getPriority());
  representation.setFilterClass(getFilterClass());
  representation.setSupportsPartialRendering(supportsPartialRendering());
  representation.setTextId(getTextId());
  representation.setEditorId(getEditorId());
  representation.setButtonId(getButtonId());
  representation.setOverlayId(getOverlayId());
  representation.setOverlayOnly(getOverlayOnly());
  representation.setShowEditingControls(showEditingControls());
  representation.setShowParameterValue(showParameterValue());
  representation.setShowUtilityPanel(showUtilityPanel());
  representation.mTempRepresentation=null;
  if (DEBUG) {
    Log.v(LOGTAG,"String_Node_Str" + this + "String_Node_Str"+ representation+ "String_Node_Str");
  }
  return representation;
}
Program: 38410
Project: 38410
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (getParameters() == null || getParameters().getFxBitmap() == null) {
    return bitmap;
  }
  int w=bitmap.getWidth();
  int h=bitmap.getHeight();
  int fxw=getParameters().getFxBitmap().getWidth();
  int fxh=getParameters().getFxBitmap().getHeight();
  nativeApplyFilter(bitmap,w,h,getParameters().getFxBitmap(),fxw,fxh);
  return bitmap;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (getParameters() == null || mResources == null) {
    return bitmap;
  }
  int w=bitmap.getWidth();
  int h=bitmap.getHeight();
  if (mFxBitmap == null || mFxBitmapId != getParameters().getBitmapResource()) {
    BitmapFactory.Options o=new BitmapFactory.Options();
    o.inScaled=false;
    mFxBitmapId=getParameters().getBitmapResource();
    mFxBitmap=BitmapFactory.decodeResource(mResources,mFxBitmapId,o);
  }
  if (mFxBitmap == null) {
    return bitmap;
  }
  int fxw=mFxBitmap.getWidth();
  int fxh=mFxBitmap.getHeight();
  nativeApplyFilter(bitmap,w,h,mFxBitmap,fxw,fxh);
  return bitmap;
}
Program: 38411
Project: 38411
Buggy source:
public ImagePreset(ImagePreset source){
  try {
    if (source.mBorder != null) {
      mBorder=source.mBorder.clone();
    }
    for (int i=0; i < source.mFilters.size(); i++) {
      FilterRepresentation representation=source.mFilters.elementAt(i).clone();
      addFilter(representation);
    }
  }
 catch (  java.lang.CloneNotSupportedException e) {
    Log.v(LOGTAG,"String_Node_Str" + e);
  }
  mName=source.name();
  mHistoryName=source.name();
  mIsFxPreset=source.isFx();
  mImageLoader=source.getImageLoader();
  mGeoData.set(source.mGeoData);
}

Fixed version (ground truth):
public ImagePreset(ImagePreset source){
  try {
    if (source.mBorder != null) {
      mBorder=source.mBorder.clone();
    }
    for (int i=0; i < source.mFilters.size(); i++) {
      FilterRepresentation representation=source.mFilters.elementAt(i).clone();
      addFilter(representation);
    }
  }
 catch (  java.lang.CloneNotSupportedException e) {
    Log.v(LOGTAG,"String_Node_Str" + e);
  }
  mName=source.name();
  mHistoryName=source.name();
  mIsFxPreset=source.isFx();
  mImageLoader=source.getImageLoader();
  mPreviewImage=source.getPreviewImage();
  mGeoData.set(source.mGeoData);
}
Program: 38412
Project: 38412
Buggy source:
private void buildExposureCompensation(PreferenceGroup group,IconListPreference exposure){
  int max=mParameters.getMaxExposureCompensation();
  int min=mParameters.getMinExposureCompensation();
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=mParameters.getExposureCompensationStep();
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  int[] icons=new int[maxValue - minValue + 1];
  TypedArray iconIds=mContext.getResources().obtainTypedArray(R.array.pref_camera_exposure_icons);
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
    icons[maxValue - i]=iconIds.getResourceId(3 + i,0);
  }
  exposure.setUseSingleIcon(true);
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
  exposure.setLargeIconIds(icons);
}

Fixed version (ground truth):
private void buildExposureCompensation(PreferenceGroup group,IconListPreference exposure){
  int max=Math.min(3,mParameters.getMaxExposureCompensation());
  int min=Math.max(-3,mParameters.getMinExposureCompensation());
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=mParameters.getExposureCompensationStep();
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  int[] icons=new int[maxValue - minValue + 1];
  TypedArray iconIds=mContext.getResources().obtainTypedArray(R.array.pref_camera_exposure_icons);
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
    icons[maxValue - i]=iconIds.getResourceId(3 + i,0);
  }
  exposure.setUseSingleIcon(true);
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
  exposure.setLargeIconIds(icons);
}
Program: 38413
Project: 38413
Buggy source:
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterFxRepresentation representation=(FilterFxRepresentation)super.clone();
  representation.setName(getName());
  representation.setBitmapResource(getBitmapResource());
  representation.setNameResource(getNameResource());
  representation.setFxBitmap(getFxBitmap());
  return representation;
}

Fixed version (ground truth):
@Override public synchronized FilterRepresentation clone() throws CloneNotSupportedException {
  FilterFxRepresentation representation=(FilterFxRepresentation)super.clone();
  representation.setName(getName());
  representation.setBitmapResource(getBitmapResource());
  representation.setNameResource(getNameResource());
  return representation;
}
Program: 38414
Project: 38414
Buggy source:
public void useParametersFrom(FilterRepresentation a){
  if (a instanceof FilterFxRepresentation) {
    FilterFxRepresentation representation=(FilterFxRepresentation)a;
    setName(representation.getName());
    setBitmapResource(representation.getBitmapResource());
    setNameResource(representation.getNameResource());
    setFxBitmap(representation.getFxBitmap());
  }
}

Fixed version (ground truth):
public synchronized void useParametersFrom(FilterRepresentation a){
  if (a instanceof FilterFxRepresentation) {
    FilterFxRepresentation representation=(FilterFxRepresentation)a;
    setName(representation.getName());
    setBitmapResource(representation.getBitmapResource());
    setNameResource(representation.getNameResource());
  }
}
Program: 38415
Project: 38415
Buggy source:
public String toString(){
  return "String_Node_Str" + getName();
}

Fixed version (ground truth):
public String toString(){
  return "String_Node_Str" + hashCode() + "String_Node_Str"+ getName()+ "String_Node_Str"+ mBitmapResource;
}
Program: 38416
Project: 38416
Buggy source:
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterRepresentation representation=(FilterRepresentation)super.clone();
  representation.setName(getName());
  representation.setPriority(getPriority());
  representation.setFilterClass(getFilterClass());
  representation.setSupportsPartialRendering(supportsPartialRendering());
  representation.setTextId(getTextId());
  representation.setEditorId(getEditorId());
  representation.setButtonId(getButtonId());
  representation.setOverlayId(getOverlayId());
  representation.setOverlayOnly(getOverlayOnly());
  representation.setShowEditingControls(showEditingControls());
  representation.setShowParameterValue(showParameterValue());
  representation.setShowUtilityPanel(showUtilityPanel());
  Log.v(LOGTAG,"String_Node_Str" + this + "String_Node_Str"+ representation+ "String_Node_Str");
  return representation;
}

Fixed version (ground truth):
@Override public FilterRepresentation clone() throws CloneNotSupportedException {
  FilterRepresentation representation=(FilterRepresentation)super.clone();
  representation.setName(getName());
  representation.setPriority(getPriority());
  representation.setFilterClass(getFilterClass());
  representation.setSupportsPartialRendering(supportsPartialRendering());
  representation.setTextId(getTextId());
  representation.setEditorId(getEditorId());
  representation.setButtonId(getButtonId());
  representation.setOverlayId(getOverlayId());
  representation.setOverlayOnly(getOverlayOnly());
  representation.setShowEditingControls(showEditingControls());
  representation.setShowParameterValue(showParameterValue());
  representation.setShowUtilityPanel(showUtilityPanel());
  representation.mTempRepresentation=null;
  if (DEBUG) {
    Log.v(LOGTAG,"String_Node_Str" + this + "String_Node_Str"+ representation+ "String_Node_Str");
  }
  return representation;
}
Program: 38417
Project: 38417
Buggy source:
public ImagePreset(ImagePreset source){
  try {
    if (source.mBorder != null) {
      mBorder=source.mBorder.clone();
    }
    for (int i=0; i < source.mFilters.size(); i++) {
      FilterRepresentation representation=source.mFilters.elementAt(i).clone();
      addFilter(representation);
    }
  }
 catch (  java.lang.CloneNotSupportedException e) {
    Log.v(LOGTAG,"String_Node_Str" + e);
  }
  mName=source.name();
  mHistoryName=source.name();
  mIsFxPreset=source.isFx();
  mImageLoader=source.getImageLoader();
  mGeoData.set(source.mGeoData);
}

Fixed version (ground truth):
public ImagePreset(ImagePreset source){
  try {
    if (source.mBorder != null) {
      mBorder=source.mBorder.clone();
    }
    for (int i=0; i < source.mFilters.size(); i++) {
      FilterRepresentation representation=source.mFilters.elementAt(i).clone();
      addFilter(representation);
    }
  }
 catch (  java.lang.CloneNotSupportedException e) {
    Log.v(LOGTAG,"String_Node_Str" + e);
  }
  mName=source.name();
  mHistoryName=source.name();
  mIsFxPreset=source.isFx();
  mImageLoader=source.getImageLoader();
  mPreviewImage=source.getPreviewImage();
  mGeoData.set(source.mGeoData);
}
Program: 38418
Project: 38418
Buggy source:
private void buildExposureCompensation(PreferenceGroup group,IconListPreference exposure){
  int max=mParameters.getMaxExposureCompensation();
  int min=mParameters.getMinExposureCompensation();
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=mParameters.getExposureCompensationStep();
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  int[] icons=new int[maxValue - minValue + 1];
  TypedArray iconIds=mContext.getResources().obtainTypedArray(R.array.pref_camera_exposure_icons);
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
    icons[maxValue - i]=iconIds.getResourceId(3 + i,0);
  }
  exposure.setUseSingleIcon(true);
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
  exposure.setLargeIconIds(icons);
}

Fixed version (ground truth):
private void buildExposureCompensation(PreferenceGroup group,IconListPreference exposure){
  int max=Math.min(3,mParameters.getMaxExposureCompensation());
  int min=Math.max(-3,mParameters.getMinExposureCompensation());
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=mParameters.getExposureCompensationStep();
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  int[] icons=new int[maxValue - minValue + 1];
  TypedArray iconIds=mContext.getResources().obtainTypedArray(R.array.pref_camera_exposure_icons);
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
    icons[maxValue - i]=iconIds.getResourceId(3 + i,0);
  }
  exposure.setUseSingleIcon(true);
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
  exposure.setLargeIconIds(icons);
}
Program: 38419
Project: 38419
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.undoButton:
{
      HistoryAdapter adapter=mMasterImage.getHistory();
      int position=adapter.undo();
      mMasterImage.onHistoryItemClick(position);
      mImageShow.showToast("String_Node_Str");
      invalidateViews();
      return true;
    }
case R.id.redoButton:
{
    HistoryAdapter adapter=mMasterImage.getHistory();
    int position=adapter.redo();
    mMasterImage.onHistoryItemClick(position);
    mImageShow.showToast("String_Node_Str");
    invalidateViews();
    return true;
  }
case R.id.resetHistoryButton:
{
  resetHistory();
  return true;
}
case R.id.showImageStateButton:
{
toggleImageStatePanel();
return true;
}
case R.id.operationsButton:
{
toggleHistoryPanel();
return true;
}
case android.R.id.home:
{
saveImage();
return true;
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.undoButton:
{
      mPanelController.resetParameters();
      HistoryAdapter adapter=mMasterImage.getHistory();
      int position=adapter.undo();
      mMasterImage.onHistoryItemClick(position);
      mImageShow.showToast("String_Node_Str");
      invalidateViews();
      return true;
    }
case R.id.redoButton:
{
    HistoryAdapter adapter=mMasterImage.getHistory();
    int position=adapter.redo();
    mMasterImage.onHistoryItemClick(position);
    mImageShow.showToast("String_Node_Str");
    invalidateViews();
    return true;
  }
case R.id.resetHistoryButton:
{
  resetHistory();
  return true;
}
case R.id.showImageStateButton:
{
toggleImageStatePanel();
return true;
}
case R.id.operationsButton:
{
toggleHistoryPanel();
return true;
}
case android.R.id.home:
{
saveImage();
return true;
}
}
return false;
}
Program: 38420
Project: 38420
Buggy source:
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.undoButton:
{
      HistoryAdapter adapter=mMasterImage.getHistory();
      int position=adapter.undo();
      mMasterImage.onHistoryItemClick(position);
      mImageShow.showToast("String_Node_Str");
      invalidateViews();
      return true;
    }
case R.id.redoButton:
{
    HistoryAdapter adapter=mMasterImage.getHistory();
    int position=adapter.redo();
    mMasterImage.onHistoryItemClick(position);
    mImageShow.showToast("String_Node_Str");
    invalidateViews();
    return true;
  }
case R.id.resetHistoryButton:
{
  resetHistory();
  return true;
}
case R.id.showImageStateButton:
{
toggleImageStatePanel();
return true;
}
case R.id.operationsButton:
{
toggleHistoryPanel();
return true;
}
case android.R.id.home:
{
saveImage();
return true;
}
}
return false;
}

Fixed version (ground truth):
@Override public boolean onOptionsItemSelected(MenuItem item){
switch (item.getItemId()) {
case R.id.undoButton:
{
      mPanelController.resetParameters();
      HistoryAdapter adapter=mMasterImage.getHistory();
      int position=adapter.undo();
      mMasterImage.onHistoryItemClick(position);
      mImageShow.showToast("String_Node_Str");
      invalidateViews();
      return true;
    }
case R.id.redoButton:
{
    HistoryAdapter adapter=mMasterImage.getHistory();
    int position=adapter.redo();
    mMasterImage.onHistoryItemClick(position);
    mImageShow.showToast("String_Node_Str");
    invalidateViews();
    return true;
  }
case R.id.resetHistoryButton:
{
  resetHistory();
  return true;
}
case R.id.showImageStateButton:
{
toggleImageStatePanel();
return true;
}
case R.id.operationsButton:
{
toggleHistoryPanel();
return true;
}
case android.R.id.home:
{
saveImage();
return true;
}
}
return false;
}
Program: 38422
Project: 38422
Buggy source:
@Override protected void onDestroy(){
  if (mLoadBitmapTask != null) {
    mLoadBitmapTask.cancel(false);
  }
  MasterImage.reset();
  FilteringPipeline.reset();
  ImageFilter.reset();
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  if (mLoadBitmapTask != null) {
    mLoadBitmapTask.cancel(false);
  }
  super.onDestroy();
}
Program: 38423
Project: 38423
Buggy source:
public static FilteringPipeline getPipeline(){
  if (sPipeline == null) {
    sPipeline=new FilteringPipeline();
  }
  return sPipeline;
}

Fixed version (ground truth):
public static FilteringPipeline getPipeline(){
  return gPipeline;
}
Program: 38424
Project: 38424
Buggy source:
public Bitmap getScaleOneImageForPreset(ImageShow caller,ImagePreset imagePreset,Rect bounds,Rect destination,boolean force){
  mLoadingLock.lock();
  Bitmap bmp=mZoomCache.getImage(imagePreset,bounds);
  if (force || bmp == null) {
    BitmapFactory.Options options=null;
    if (destination != null) {
      options=new BitmapFactory.Options();
      if (bounds.width() > destination.width()) {
        int sampleSize=1;
        int w=bounds.width();
        while (w > destination.width()) {
          sampleSize*=2;
          w/=sampleSize;
        }
        options.inSampleSize=sampleSize;
      }
    }
    bmp=loadRegionBitmap(mUri,options,bounds);
    if (bmp != null) {
      float scaleFactor=imagePreset.getScaleFactor();
      imagePreset.setScaleFactor(1.0f);
      bmp=imagePreset.apply(bmp);
      imagePreset.setScaleFactor(scaleFactor);
      mZoomCache.setImage(imagePreset,bounds,bmp);
      mLoadingLock.unlock();
      return bmp;
    }
  }
  mLoadingLock.unlock();
  return bmp;
}

Fixed version (ground truth):
public Bitmap getScaleOneImageForPreset(ImageShow caller,ImagePreset imagePreset,Rect bounds,Rect destination,boolean force){
  mLoadingLock.lock();
  Bitmap bmp=mZoomCache.getImage(imagePreset,bounds);
  if (force || bmp == null) {
    BitmapFactory.Options options=null;
    if (destination != null) {
      options=new BitmapFactory.Options();
      if (bounds.width() > destination.width()) {
        int sampleSize=1;
        int w=bounds.width();
        while (w > destination.width()) {
          sampleSize*=2;
          w/=sampleSize;
        }
        options.inSampleSize=sampleSize;
      }
    }
    bmp=loadRegionBitmap(mUri,options,bounds);
    if (bmp != null) {
      Bitmap bmp2=bmp.copy(Bitmap.Config.ARGB_8888,true);
      float scaleFactor=imagePreset.getScaleFactor();
      imagePreset.setScaleFactor(1.0f);
      bmp2=imagePreset.apply(bmp2);
      imagePreset.setScaleFactor(scaleFactor);
      mZoomCache.setImage(imagePreset,bounds,bmp2);
      mLoadingLock.unlock();
      return bmp2;
    }
  }
  mLoadingLock.unlock();
  return bmp;
}
Program: 38425
Project: 38425
Buggy source:
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (bitmap == null) {
    return bitmap;
  }
  try {
    prepare(bitmap,scaleFactor,quality);
    runFilter();
    update(bitmap);
  }
 catch (  android.renderscript.RSIllegalArgumentException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  android.renderscript.RSRuntimeException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  java.lang.OutOfMemoryError e) {
    System.gc();
    displayLowMemoryToast();
    Log.e(LOGTAG,"String_Node_Str" + getName(),e);
  }
  return bitmap;
}

Fixed version (ground truth):
@Override public Bitmap apply(Bitmap bitmap,float scaleFactor,int quality){
  if (bitmap == null) {
    return bitmap;
  }
  try {
    prepare(bitmap,scaleFactor,quality);
    runFilter();
    update(bitmap);
  }
 catch (  android.renderscript.RSIllegalArgumentException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
catch (  android.renderscript.RSRuntimeException e) {
    Log.e(LOGTAG,"String_Node_Str" + e);
  }
  return bitmap;
}
Program: 38427
Project: 38427
Buggy source:
@Override protected void onDestroy(){
  if (mLoadBitmapTask != null) {
    mLoadBitmapTask.cancel(false);
  }
  super.onDestroy();
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  if (mLoadBitmapTask != null) {
    mLoadBitmapTask.cancel(false);
  }
  MasterImage.reset();
  FilteringPipeline.reset();
  ImageFilter.resetStatics();
  super.onDestroy();
}
Program: 38428
Project: 38428
Buggy source:
public static FilteringPipeline getPipeline(){
  return gPipeline;
}

Fixed version (ground truth):
public static FilteringPipeline getPipeline(){
  if (sPipeline == null) {
    sPipeline=new FilteringPipeline();
  }
  return sPipeline;
}