Program: 173701
Project: 173701
Buggy source:
@Override public boolean sellShares(SellShares action){
  Portfolio portfolio=operatingCompany.getPortfolio();
  String errMsg=null;
  String companyName=action.getCompanyName();
  PublicCompanyI company=companyManager.getPublicCompany(companyName);
  PublicCertificateI cert=null;
  List<PublicCertificateI> certsToSell=new ArrayList<PublicCertificateI>();
  int numberToSell=action.getNumberSold();
  int shareUnits=action.getShareUnits();
  while (true) {
    if (numberToSell <= 0) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (company == null) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (company != operatingCompany) {
      errMsg=LocalText.getText("String_Node_Str",companyName,operatingCompany.getName());
      break;
    }
    if (!company.hasFloated()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (company.mustHaveOperatedToTradeShares() && !company.hasOperated()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (hasSold.booleanValue()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (portfolio.getShare(company) < numberToSell) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (pool.getShare(company) + numberToSell * company.getShareUnit() > getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    Iterator<PublicCertificateI> it=portfolio.getCertificatesPerCompany(companyName).iterator();
    while (numberToSell > 0 && it.hasNext()) {
      cert=it.next();
      if (shareUnits != cert.getShares()) {
        continue;
      }
      certsToSell.add(cert);
      numberToSell--;
    }
    if (numberToSell > 0) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    break;
  }
  int numberSold=action.getNumberSold();
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",companyName,numberSold,companyName,errMsg));
    return false;
  }
  StockSpaceI sellPrice;
  int price;
  if (sellPrices.containsKey(companyName)) {
    price=(sellPrices.get(companyName)).getPrice();
  }
 else {
    sellPrice=company.getCurrentSpace();
    price=sellPrice.getPrice();
    sellPrices.put(companyName,sellPrice);
  }
  moveStack.start(true);
  ReportBuffer.add(LocalText.getText("String_Node_Str",companyName,numberSold,company.getShareUnit(),(numberSold * company.getShareUnit()),companyName,Bank.format(numberSold * price)));
  for (  PublicCertificateI cert2 : certsToSell) {
    if (cert2 != null) {
      executeTradeCertificate(cert2,pool,cert2.getShares() * price);
    }
  }
  stockMarket.sell(company,numberSold);
  hasSold.set(true);
  return true;
}

Fixed version (ground truth):
@Override public boolean sellShares(SellShares action){
  Portfolio portfolio=operatingCompany.getPortfolio();
  String errMsg=null;
  String companyName=action.getCompanyName();
  PublicCompanyI company=companyManager.getPublicCompany(companyName);
  PublicCertificateI cert=null;
  List<PublicCertificateI> certsToSell=new ArrayList<PublicCertificateI>();
  int numberToSell=action.getNumberSold();
  int shareUnits=action.getShareUnits();
  while (true) {
    if (numberToSell <= 0) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (company == null) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (company != operatingCompany) {
      errMsg=LocalText.getText("String_Node_Str",companyName,operatingCompany.getName());
      break;
    }
    if (!company.hasFloated()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (company.mustHaveOperatedToTradeShares() && !company.hasOperated()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (hasBought.booleanValue()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (portfolio.getShare(company) < numberToSell) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    if (pool.getShare(company) + numberToSell * company.getShareUnit() > getGameParameterAsInt(GameDef.Parm.POOL_SHARE_LIMIT)) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    Iterator<PublicCertificateI> it=portfolio.getCertificatesPerCompany(companyName).iterator();
    while (numberToSell > 0 && it.hasNext()) {
      cert=it.next();
      if (shareUnits != cert.getShares()) {
        continue;
      }
      certsToSell.add(cert);
      numberToSell--;
    }
    if (numberToSell > 0) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    break;
  }
  int numberSold=action.getNumberSold();
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",companyName,numberSold,companyName,errMsg));
    return false;
  }
  StockSpaceI sellPrice;
  int price;
  if (sellPrices.containsKey(companyName)) {
    price=(sellPrices.get(companyName)).getPrice();
  }
 else {
    sellPrice=company.getCurrentSpace();
    price=sellPrice.getPrice();
    sellPrices.put(companyName,sellPrice);
  }
  moveStack.start(true);
  ReportBuffer.add(LocalText.getText("String_Node_Str",companyName,numberSold,company.getShareUnit(),(numberSold * company.getShareUnit()),companyName,Bank.format(numberSold * price)));
  for (  PublicCertificateI cert2 : certsToSell) {
    if (cert2 != null) {
      executeTradeCertificate(cert2,pool,cert2.getShares() * price);
    }
  }
  stockMarket.sell(company,numberSold);
  hasSold.set(true);
  return true;
}