[Demonstration 1]

[Buggy Method]
protected void onRegisterPressed(View view) {
    int typeOfError = checkValidInputs();
    if (typeOfError == 0) {
        mAuth.createUserWithEmailAndPassword(name.getText().toString(), password.getText().toString()).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {

            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {
                Log.d(TAG, "createUserWithEmail:onComplete:" + task.isSuccessful());
                // If sign in fails, display a message to the user. If sign in succeeds
                // the auth state listener will be notified and logic to handle the
                // signed in user can be handled in the listener.
                if (!task.isSuccessful()) {
                    errorText.setText("Error: Unable to creat user.");
                } else {
                    Intent next = new Intent(RegistrationActivity.this, ProfileActivity.class);
                    startActivity(next);
                    finish();
                }
                // ...
            }
        });
    } else if (typeOfError == 1) {
        new AlertDialog.Builder(this).setTitle("Error: Invalid Username").setMessage("Please enter a valid username").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // continue with delete
            }
        }).setIcon(android.R.drawable.ic_dialog_alert).show();
    } else if (typeOfError == 2) {
        new AlertDialog.Builder(this).setTitle("Error: Passwords do not match").setMessage("Please enter passwords again").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // continue with delete
            }
        }).setIcon(android.R.drawable.ic_dialog_alert).show();
    } else if (typeOfError == 3) {
        new AlertDialog.Builder(this).setTitle("Error: Invalid Password").setMessage("Please enter a password").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // continue with delete
            }
        }).setIcon(android.R.drawable.ic_dialog_alert).show();
    } else if (typeOfError == 4) {
        new AlertDialog.Builder(this).setTitle("Error: Invalid ID").setMessage("Please enter a valid ID").setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                // continue with delete
            }
        }).setIcon(android.R.drawable.ic_dialog_alert).show();
    }
}

[Buggy Hunk]
errorText.setText("Error: Unable to creat user.");

[Patch]
errorText.setText(getResources().getString(R.string.unable_error));

[Demonstration 2]

[Buggy Method]
@Override
public Dialog onCreateDialog(Bundle saved) {
    readArgs();
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.diag_add_event, (ViewGroup) getActivity().findViewById(android.R.id.content), false);
    AlertDialog out = new AlertDialog.Builder(getActivity()).setTitle(event.getName()).setView(view).setPositiveButton("Continue", new ContinueHandler()).setNegativeButton("Cancel", new CancelHandler()).create();
    loading = view.findViewById(R.id.d_addevent_loading);
    location = (TextView) view.findViewById(R.id.d_addevent_location);
    address = (TextView) view.findViewById(R.id.d_addevent_address);
    msg = (TextView) view.findViewById(R.id.d_addevent_msg);
    addressRow = view.findViewById(R.id.d_addevent_address_row);
    location.setText(event.getLocation());
    context = getActivity().getApplicationContext();
    new Worker(false).execute();
    return out;
}

[Buggy Hunk]
new Worker(false).execute();

[Patch]
new Worker().execute();

[Demonstration 3]

[Buggy Method]
public boolean reachesTargetAddress(MemoryDump memoryDump, long memoryDumpStartingOffset) throws IOException {
    File memoryDumpFile = memoryDump.getBinaryFilePath().toFile();
    try (RandomAccessFile memoryDumpReader = new RandomAccessFile(memoryDumpFile, "r")) {
        long relativeBaseAddress = baseAddress - memoryDumpStartingOffset;
        memoryDumpReader.seek(relativeBaseAddress);
        long baseAddressValue = memoryDumpReader.readInt();
        long pointerDestination = -1;
        for (int pointerOffset : offsets) {
            pointerDestination = baseAddressValue + pointerOffset;
            long relativeOffset = pointerDestination - memoryDumpStartingOffset;
            if (relativeOffset < 0 || relativeOffset > memoryDumpReader.length()) {
                return false;
            }
            memoryDumpReader.seek(relativeOffset);
            baseAddressValue = memoryDumpReader.readInt();
        }
        return pointerDestination == memoryDump.getTargetAddress();
    }
}

[Buggy Hunk]
if (relativeOffset < 0 || relativeOffset > memoryDumpReader.length())

[Patch]
if (relativeOffset < 0 || relativeOffset > memoryDumpReader.length() - 4)