Program: 41371
Project: 41371
Buggy source:
private void processKeyEvent(int keyCode){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    clearFocus();
  }
 else   if (keyCode == KeyEvent.KEYCODE_DEL) {
    startBlinking();
switch (mMode) {
case CVC:
      if (mCVC.length() > 0) {
        removeLastChar(mCVC);
        checkIsCompleted();
        break;
      }
 else {
        mMode=Mode.EXPIRYYEAR;
      }
case EXPIRYYEAR:
    if (mYear.length() > 0) {
      removeLastChar(mYear);
      removeLastChar(mExpiryFormatted);
      break;
    }
 else {
      removeLastChar(mExpiryFormatted);
      mMode=Mode.EXPIRYMONTH;
    }
case EXPIRYMONTH:
  if (mMonth.length() > 0) {
    removeLastChar(mMonth);
    removeLastChar(mExpiryFormatted);
    break;
  }
 else {
    mMode=Mode.NUMBER;
    mAnimator.reverse();
  }
case NUMBER:
if (mNumber.length() > 0) {
  removeLastChar(mNumber);
  removeLastChar(mNumberFormatted);
  if (mCardType.hasBreakAt(mNumber.length() + 1)) {
    removeLastChar(mNumberFormatted);
  }
  if (mNumber.length() < 2) {
    setCardType(CardType.UNKNOWN);
  }
}
break;
}
mError=false;
}
 else if (!mError) {
startBlinking();
int number=keyCode - KeyEvent.KEYCODE_0;
if ((number >= 0) && (number <= 9)) {
String numberAsString=Integer.toString(number);
switch (mMode) {
case NUMBER:
mNumber.append(numberAsString);
mNumberFormatted.append(numberAsString);
int length=mNumber.length();
if (mCardType.hasBreakAt(length)) {
mNumberFormatted.append(' ');
}
if (length < 2) {
}
 else if (length == 2) {
setCardType(guessCardType(mNumber));
}
 else if (mCardType.isCorrectLength(length)) {
validateNumber();
}
break;
case EXPIRYMONTH:
if (mMonth.length() == 0) {
if ((number == 0) || (number == 1)) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (mMonth.length() == 1) {
if (mMonth.charAt(0) == '1') {
if ((number == 0) || (number == 1) || (number == 2)) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (number != 0) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
if (mMonth.length() == 2) {
int month=Integer.parseInt(mMonth.toString());
if ((month >= 1) && (month <= 12)) {
mExpiryFormatted.append('/');
mMode=Mode.EXPIRYYEAR;
}
}
}
break;
case EXPIRYYEAR:
final int yearLength=mYear.length();
if (yearLength == 0) {
if (number >= 1) {
mYear.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (yearLength == 1) {
mYear.append(numberAsString);
Calendar calendar=Calendar.getInstance();
int actualYear=calendar.get(Calendar.YEAR);
int enteredYear=2000 + Integer.parseInt(mYear.toString());
if (actualYear == enteredYear) {
int actualMonth=calendar.get(Calendar.MONTH) + 1;
int enteredMonth=Integer.parseInt(mMonth.toString());
if (actualMonth > enteredMonth) {
mExpiryFormatted.append(numberAsString);
mMode=Mode.CVC;
}
}
 else if (actualYear < enteredYear) {
mExpiryFormatted.append(numberAsString);
mMode=Mode.CVC;
}
}
break;
case CVC:
if (mCVC.length() < mCardType.mCVCLength) {
mCVC.append(numberAsString);
checkIsCompleted();
}
break;
}
}
}
postInvalidate();
}

Fixed version (ground truth):
private void processKeyEvent(int keyCode){
  if (keyCode == KeyEvent.KEYCODE_BACK) {
    clearFocus();
  }
 else   if (keyCode == KeyEvent.KEYCODE_DEL) {
    startBlinking();
switch (mMode) {
case CVC:
      if (mCVC.length() > 0) {
        removeLastChar(mCVC);
        checkIsCompleted();
        break;
      }
 else {
        mMode=Mode.EXPIRYYEAR;
      }
case EXPIRYYEAR:
    if (mYear.length() > 0) {
      removeLastChar(mYear);
      removeLastChar(mExpiryFormatted);
      break;
    }
 else {
      removeLastChar(mExpiryFormatted);
      mMode=Mode.EXPIRYMONTH;
    }
case EXPIRYMONTH:
  if (mMonth.length() > 0) {
    removeLastChar(mMonth);
    removeLastChar(mExpiryFormatted);
    break;
  }
 else {
    mMode=Mode.NUMBER;
    mAnimator.reverse();
  }
case NUMBER:
if (mNumber.length() > 0) {
  removeLastChar(mNumber);
  removeLastChar(mNumberFormatted);
  if (mCardType.hasBreakAt(mNumber.length() + 1)) {
    removeLastChar(mNumberFormatted);
  }
  if (mNumber.length() < 2) {
    setCardType(CardType.UNKNOWN);
  }
}
break;
}
mError=false;
}
 else if (!mError) {
startBlinking();
int number=keyCode - KeyEvent.KEYCODE_0;
if ((number >= 0) && (number <= 9)) {
String numberAsString=Integer.toString(number);
switch (mMode) {
case NUMBER:
mNumber.append(numberAsString);
mNumberFormatted.append(numberAsString);
int length=mNumber.length();
if (mCardType.hasBreakAt(length)) {
mNumberFormatted.append(' ');
}
if (length < 2) {
}
 else if (length == 2) {
setCardType(guessCardType(mNumber));
}
 else if (mCardType.isCorrectLength(length)) {
validateNumber();
}
break;
case EXPIRYMONTH:
if (mMonth.length() == 0) {
if ((number == 0) || (number == 1)) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (mMonth.length() == 1) {
if (mMonth.charAt(0) == '1') {
if ((number == 0) || (number == 1) || (number == 2)) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (number != 0) {
mMonth.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
if (mMonth.length() == 2) {
int month=Integer.parseInt(mMonth.toString());
if ((month >= 1) && (month <= 12)) {
mExpiryFormatted.append('/');
mMode=Mode.EXPIRYYEAR;
}
}
}
break;
case EXPIRYYEAR:
final int yearLength=mYear.length();
if (yearLength == 0) {
if (number >= 1) {
mYear.append(numberAsString);
mExpiryFormatted.append(numberAsString);
}
}
 else if (yearLength == 1) {
mYear.append(numberAsString);
Calendar calendar=Calendar.getInstance();
int actualYear=calendar.get(Calendar.YEAR);
int enteredYear=2000 + Integer.parseInt(mYear.toString());
if (actualYear == enteredYear) {
int actualMonth=calendar.get(Calendar.MONTH) + 1;
int enteredMonth=Integer.parseInt(mMonth.toString());
if (actualMonth <= enteredMonth) {
mExpiryFormatted.append(numberAsString);
mMode=Mode.CVC;
}
}
 else if (actualYear < enteredYear) {
mExpiryFormatted.append(numberAsString);
mMode=Mode.CVC;
}
}
break;
case CVC:
if (mCVC.length() < mCardType.mCVCLength) {
mCVC.append(numberAsString);
checkIsCompleted();
}
break;
}
}
}
postInvalidate();
}