[Demonstration 1]

[Buggy Method]
public void surfaceChanged(SurfaceHolder _holder, int format, int width, int height) {
    Log.i(TAG, "surfaceCreated");
    if (mCamera != null) {
        Camera.Parameters params = mCamera.getParameters();
        List<Camera.Size> sizes = params.getSupportedPreviewSizes();
        mFrameWidth = width;
        mFrameHeight = height;
        // selecting optimal camera preview size
        {
            double minDiff = Double.MAX_VALUE;
            for (Camera.Size size : sizes) {
                if (Math.abs(size.height - height) < minDiff) {
                    mFrameWidth = size.width;
                    mFrameHeight = size.height;
                    minDiff = Math.abs(size.height - height);
                }
            }
        }
        params.setPreviewSize(getFrameWidth(), getFrameHeight());
        mCamera.setParameters(params);
        try {
            mFrame = new byte[mFrameWidth * mFrameHeight * ImageFormat.getBitsPerPixel(params.getPreviewFormat()) / 8];
            mCamera.addCallbackBuffer(mFrame);
            mCamera.setPreviewDisplay(null);
        } catch (IOException e) {
            Log.e(TAG, "mCamera.setPreviewDisplay fails: " + e);
        }
        //Recreate preview bitmap
        mBmp.recycle();
        mBmp = Bitmap.createBitmap(mFrameWidth, mFrameHeight, Bitmap.Config.ARGB_8888);
        //Start preview
        mCamera.startPreview();
    }
}

[Buggy Hunk]
mBmp.recycle();

[Patch]
if(mBmp != null) mBmp.recycle();

[Demonstration 2]

[Buggy Method]
public static Bitmap flipVertically(Bitmap bitmap) {
    Bitmap newBitmap;
    Matrix matrix = new Matrix();
    matrix.preScale(1, -1);
    newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
    return newBitmap;
}

[Buggy Hunk]
Matrix matrix = new Matrix();

[Patch]
matrix.reset();

[Demonstration 3]

[Buggy Method]
private void checkBounds() {
    if (position.x < 0)
        position.x = 0;
    if (position.x > 1000)
        position.x = 0;
    if (position.y < 10)
        position.y = 10;
    if (position.z > 0)
        position.z = 0;
    if (position.z < -1000)
        position.z = -1000;
}

[Buggy Hunk]
if (position.x > 1000) position.x = 0;

[Patch]
if (position.x > 1000) position.x = 1000;