Program: 51942
Project: 51942
Buggy source:
@Override public void layout(){
  super.layout();
  if (this instanceof XulDeck) {
    return;
  }
  if (!(getManagedObject() instanceof Composite)) {
    return;
  }
  Composite container=(Composite)getManagedObject();
  int totalFlex=0;
  int thisFlex=0;
  boolean everyChildIsFlexing=true;
  for (  Object child : this.getChildNodes()) {
    thisFlex=((SwtElement)child).getFlex();
    if (thisFlex <= 0) {
      everyChildIsFlexing=false;
    }
    totalFlex+=thisFlex;
  }
switch (orient) {
case HORIZONTAL:
    int columnCount=this.getChildNodes().size() + totalFlex;
  container.setLayout(new GridLayout(columnCount,everyChildIsFlexing));
break;
case VERTICAL:
container.setLayout(new GridLayout());
break;
}
for (Object child : this.getChildNodes()) {
SwtElement swtChild=(SwtElement)child;
Object mo=swtChild.getManagedObject();
if (mo == null || !(mo instanceof Control) || swtChild instanceof XulDialog) {
continue;
}
Control c=(Control)swtChild.getManagedObject();
GridData data=new GridData();
data.horizontalSpan=orient.equals(Orient.HORIZONTAL) ? swtChild.getFlex() + 1 : 1;
data.verticalSpan=orient.equals(Orient.VERTICAL) ? swtChild.getFlex() + 1 : 1;
switch (orient) {
case HORIZONTAL:
data.verticalAlignment=SWT.FILL;
data.grabExcessVerticalSpace=true;
break;
case VERTICAL:
data.horizontalAlignment=SWT.FILL;
data.grabExcessHorizontalSpace=true;
break;
}
if (swtChild.getFlex() > 0) {
data.grabExcessHorizontalSpace=true;
data.grabExcessVerticalSpace=true;
data.horizontalAlignment=SWT.FILL;
data.verticalAlignment=SWT.FILL;
}
if (swtChild instanceof XulContainer && ((XulContainer)swtChild).getAlign() != null) {
SwtAlign swtAlign=SwtAlign.valueOf(((XulContainer)swtChild).getAlign().toString());
if (orient.equals(Orient.HORIZONTAL)) {
data.verticalAlignment=swtAlign.getSwtAlign();
if (data.verticalAlignment == SWT.FILL) {
data.grabExcessVerticalSpace=true;
}
}
 else {
data.horizontalAlignment=swtAlign.getSwtAlign();
if (data.horizontalAlignment == SWT.FILL) {
data.grabExcessHorizontalSpace=true;
}
}
}
c.setLayoutData(data);
}
container.layout(true);
}

Fixed version (ground truth):
@Override public void layout(){
  super.layout();
  if (this instanceof XulDeck) {
    return;
  }
  if (!(getManagedObject() instanceof Composite)) {
    return;
  }
  Composite container=(Composite)getManagedObject();
  int totalFlex=0;
  int thisFlex=0;
  boolean everyChildIsFlexing=true;
  for (  Object child : this.getChildNodes()) {
    thisFlex=((SwtElement)child).getFlex();
    if (thisFlex <= 0) {
      everyChildIsFlexing=false;
    }
    totalFlex+=thisFlex;
  }
switch (orient) {
case HORIZONTAL:
    int columnCount=this.getChildNodes().size() + totalFlex;
  container.setLayout(new GridLayout(columnCount,everyChildIsFlexing));
break;
case VERTICAL:
container.setLayout(new GridLayout());
break;
}
for (Object child : this.getChildNodes()) {
SwtElement swtChild=(SwtElement)child;
Object mo=swtChild.getManagedObject();
if (mo == null || !(mo instanceof Control) || swtChild instanceof XulDialog) {
continue;
}
Control c=(Control)swtChild.getManagedObject();
GridData data=new GridData();
data.horizontalSpan=orient.equals(Orient.HORIZONTAL) ? swtChild.getFlex() + 1 : 1;
data.verticalSpan=orient.equals(Orient.VERTICAL) ? swtChild.getFlex() + 1 : 1;
switch (orient) {
case HORIZONTAL:
data.verticalAlignment=SWT.FILL;
data.grabExcessVerticalSpace=true;
break;
case VERTICAL:
data.horizontalAlignment=SWT.FILL;
data.grabExcessHorizontalSpace=true;
break;
}
if (swtChild.getFlex() > 0) {
data.grabExcessHorizontalSpace=true;
data.grabExcessVerticalSpace=true;
data.horizontalAlignment=SWT.FILL;
data.verticalAlignment=SWT.FILL;
}
if (((XulComponent)swtChild).getAlign() != null) {
SwtAlign swtAlign=SwtAlign.valueOf(((XulContainer)swtChild).getAlign().toString());
if (orient.equals(Orient.HORIZONTAL)) {
data.grabExcessVerticalSpace=true;
}
 else {
data.grabExcessHorizontalSpace=true;
}
}
c.setLayoutData(data);
}
container.layout(true);
}