Program: 51894
Project: 51894
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;
  GridLayout layout=new GridLayout(columnCount,everyChildIsFlexing);
if (this.getPadding() > -1) {
  layout.marginWidth=this.getPadding();
  layout.marginHeight=this.getPadding();
}
if (this.getSpacing() > -1) {
layout.horizontalSpacing=this.getSpacing();
layout.verticalSpacing=this.getSpacing();
}
container.setLayout(layout);
break;
case VERTICAL:
layout=new GridLayout();
if (this.getPadding() > -1) {
layout.marginWidth=this.getPadding();
layout.marginHeight=this.getPadding();
}
if (this.getSpacing() > -1) {
layout.horizontalSpacing=this.getSpacing();
layout.verticalSpacing=this.getSpacing();
}
container.setLayout(layout);
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) {
if (swtChild.getWidth() == 0) {
data.grabExcessHorizontalSpace=true;
data.horizontalAlignment=SWT.FILL;
}
if (swtChild.getHeight() == 0) {
data.grabExcessVerticalSpace=true;
data.verticalAlignment=SWT.FILL;
}
}
if (swtChild.getWidth() > 0) {
data.widthHint=swtChild.getWidth();
}
if (swtChild.getHeight() > 0) {
data.heightHint=swtChild.getHeight();
}
if (((XulComponent)swtChild).getAlign() != null) {
SwtAlign swtAlign=SwtAlign.valueOf(((XulContainer)swtChild).getAlign().toString());
if (orient.equals(Orient.HORIZONTAL)) {
if (swtChild.getHeight() < 0) {
data.grabExcessVerticalSpace=true;
}
}
 else {
if (swtChild.getWidth() < 0) {
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;
  GridLayout layout=new GridLayout(columnCount,everyChildIsFlexing);
if (this.getPadding() > -1) {
  layout.marginWidth=this.getPadding();
  layout.marginHeight=this.getPadding();
}
if (this.getSpacing() > -1) {
layout.horizontalSpacing=this.getSpacing();
layout.verticalSpacing=this.getSpacing();
}
container.setLayout(layout);
break;
case VERTICAL:
layout=new GridLayout();
if (this.getPadding() > -1) {
layout.marginWidth=this.getPadding();
layout.marginHeight=this.getPadding();
}
if (this.getSpacing() > -1) {
layout.horizontalSpacing=this.getSpacing();
layout.verticalSpacing=this.getSpacing();
}
container.setLayout(layout);
break;
}
for (Object child : this.getChildNodes()) {
SwtElement swtChild=(SwtElement)child;
Object mo=swtChild.getManagedObject();
if (mo == null || !(mo instanceof Control || mo instanceof Viewer) || swtChild instanceof XulDialog) {
continue;
}
Control c=null;
if (mo instanceof Control) {
c=(Control)mo;
}
 else if (mo instanceof Viewer) {
c=((Viewer)mo).getControl();
}
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) {
if (swtChild.getWidth() == 0) {
data.grabExcessHorizontalSpace=true;
data.horizontalAlignment=SWT.FILL;
}
if (swtChild.getHeight() == 0) {
data.grabExcessVerticalSpace=true;
data.verticalAlignment=SWT.FILL;
}
}
if (swtChild.getWidth() > 0) {
data.widthHint=swtChild.getWidth();
}
if (swtChild.getHeight() > 0) {
data.heightHint=swtChild.getHeight();
}
if (((XulComponent)swtChild).getAlign() != null) {
SwtAlign swtAlign=SwtAlign.valueOf(((XulContainer)swtChild).getAlign().toString());
if (orient.equals(Orient.HORIZONTAL)) {
if (swtChild.getHeight() < 0) {
data.grabExcessVerticalSpace=true;
}
}
 else {
if (swtChild.getWidth() < 0) {
data.grabExcessHorizontalSpace=true;
}
}
}
c.setLayoutData(data);
}
container.layout(true);
}