Program: 157330
Project: 157330
Buggy source:
public void loadKeyboard(final KeyboardDimens keyboardDimens){
  mDisplayWidth=keyboardDimens.getKeyboardMaxWidth();
  final float rowVerticalGap=keyboardDimens.getRowVerticalGap();
  final float keyHorizontalGap=keyboardDimens.getKeyHorizontalGap();
  mDefaultHorizontalGap=0;
  mDefaultWidth=mDisplayWidth / 10;
  mDefaultHeightCode=-1;
  XmlResourceParser parser=mKeyboardContext.getResources().getXml(mLayoutResId);
  boolean inKey=false;
  boolean inRow=false;
  boolean inUnknown=false;
  int row=0;
  float x=0;
  float y=rowVerticalGap;
  int rowHeight=0;
  Key key=null;
  Row currentRow=null;
  Resources res=mKeyboardContext.getResources();
  int lastVerticalGap=0;
  try {
    int event;
    while ((event=parser.next()) != XmlResourceParser.END_DOCUMENT) {
      if (event == XmlResourceParser.START_TAG) {
        String tag=parser.getName();
        if (TAG_ROW.equals(tag)) {
          inRow=true;
          x=0;
          rowHeight=0;
          currentRow=createRowFromXml(mKeyboardResourceMap,res,parser,mKeyboardMode);
          if (currentRow == null) {
            skipToEndOfRow(parser);
            inRow=false;
          }
        }
 else         if (TAG_KEY.equals(tag)) {
          inKey=true;
          x+=(keyHorizontalGap / 2);
          key=createKeyFromXml(mKeyboardResourceMap,mASKContext,mKeyboardContext,currentRow,keyboardDimens,(int)x,(int)y,parser);
          rowHeight=Math.max(rowHeight,key.height);
          key.width-=keyHorizontalGap;
          mKeys.add(key);
          if (key.getPrimaryCode() == KeyCodes.SHIFT) {
            mShiftKey=key;
            mShiftKeyIndex=mKeys.size() - 1;
            mModifierKeys.add(key);
          }
 else           if (key.getPrimaryCode() == KeyCodes.ALT) {
            mModifierKeys.add(key);
          }
        }
 else         if (TAG_KEYBOARD.equals(tag)) {
          parseKeyboardAttributes(mASKContext,res,parser);
        }
 else {
          inUnknown=true;
          Logger.w(TAG,"String_Node_Str",tag);
        }
      }
 else       if (event == XmlResourceParser.END_TAG) {
        if (inKey) {
          inKey=false;
          x+=key.gap + key.width;
          x+=(keyHorizontalGap / 2);
          if (x > mTotalWidth) {
            mTotalWidth=(int)x;
          }
        }
 else         if (inRow) {
          inRow=false;
          lastVerticalGap=currentRow.verticalGap;
          y+=currentRow.verticalGap;
          y+=rowHeight;
          y+=rowVerticalGap;
          row++;
        }
 else         if (inUnknown) {
          inUnknown=false;
        }
      }
    }
  }
 catch (  Exception e) {
    Logger.e(TAG,"String_Node_Str" + e);
    e.printStackTrace();
  }
  mTotalHeight=(int)(y - lastVerticalGap);
}

Fixed version (ground truth):
public void loadKeyboard(final KeyboardDimens keyboardDimens){
  mDisplayWidth=keyboardDimens.getKeyboardMaxWidth();
  final float rowVerticalGap=keyboardDimens.getRowVerticalGap();
  final float keyHorizontalGap=keyboardDimens.getKeyHorizontalGap();
  mDefaultHorizontalGap=0;
  mDefaultWidth=mDisplayWidth / 10;
  mDefaultHeightCode=-1;
  XmlResourceParser parser=mKeyboardContext.getResources().getXml(mLayoutResId);
  boolean inKey=false;
  boolean inRow=false;
  boolean inUnknown=false;
  int row=0;
  float x=0;
  float y=rowVerticalGap;
  int rowHeight=0;
  Key key=null;
  Row currentRow=null;
  Resources res=mKeyboardContext.getResources();
  int lastVerticalGap=0;
  try {
    int event;
    while ((event=parser.next()) != XmlResourceParser.END_DOCUMENT) {
      if (event == XmlResourceParser.START_TAG) {
        String tag=parser.getName();
        if (TAG_ROW.equals(tag)) {
          inRow=true;
          x=0;
          rowHeight=0;
          currentRow=createRowFromXml(mKeyboardResourceMap,res,parser,mKeyboardMode);
          if (currentRow == null) {
            skipToEndOfRow(parser);
            inRow=false;
          }
        }
 else         if (TAG_KEY.equals(tag)) {
          inKey=true;
          x+=(keyHorizontalGap / 2);
          key=createKeyFromXml(mKeyboardResourceMap,mASKContext,mKeyboardContext,currentRow,keyboardDimens,(int)x,(int)y,parser);
          rowHeight=Math.max(rowHeight,key.height);
          key.width-=keyHorizontalGap;
          mKeys.add(key);
          if (key.getPrimaryCode() == KeyCodes.SHIFT) {
            mShiftKey=key;
            mModifierKeys.add(key);
          }
 else           if (key.getPrimaryCode() == KeyCodes.ALT) {
            mModifierKeys.add(key);
          }
        }
 else         if (TAG_KEYBOARD.equals(tag)) {
          parseKeyboardAttributes(mASKContext,res,parser);
        }
 else {
          inUnknown=true;
          Logger.w(TAG,"String_Node_Str",tag);
        }
      }
 else       if (event == XmlResourceParser.END_TAG) {
        if (inKey) {
          inKey=false;
          x+=key.gap + key.width;
          x+=(keyHorizontalGap / 2);
          if (x > mTotalWidth) {
            mTotalWidth=(int)x;
          }
        }
 else         if (inRow) {
          inRow=false;
          lastVerticalGap=currentRow.verticalGap;
          y+=currentRow.verticalGap;
          y+=rowHeight;
          y+=rowVerticalGap;
          row++;
        }
 else         if (inUnknown) {
          inUnknown=false;
        }
      }
    }
  }
 catch (  Exception e) {
    Logger.e(TAG,"String_Node_Str" + e);
    e.printStackTrace();
  }
  mTotalHeight=(int)(y - lastVerticalGap);
}