Program: 173806
Project: 173806
Buggy source:
/** 
 * Buying one or more single or double-share certificates (more is sometimes possible)
 * @param player The player that wants to buy shares.
 * @param action The executed BuyCertificates action
 * @return True if the certificates could be bought. False indicates anerror.
 */
public boolean buyShares(String playerName,BuyCertificate action){
  PublicCertificateI cert=action.getCertificate();
  Portfolio from=cert.getPortfolio();
  String companyName=cert.getCompany().getName();
  int number=action.getNumberBought();
  int shares=number * cert.getShares();
  int shareUnit=cert.getShare();
  String errMsg=null;
  int price=0;
  int cash=0;
  PublicCompanyI company=null;
  currentPlayer=getCurrentPlayer();
  while (true) {
    if (!playerName.equals(currentPlayer.getName())) {
      errMsg=LocalText.getText("String_Node_Str",playerName);
      break;
    }
    company=companyManager.getPublicCompany(companyName);
    if (company == null) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (isSaleRecorded(currentPlayer,company)) {
      errMsg=LocalText.getText("String_Node_Str",currentPlayer.getName(),companyName);
      break;
    }
    if (!company.hasStarted()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    PublicCompanyI companyBoughtThisTurn=(PublicCompanyI)companyBoughtThisTurnWrapper.getObject();
    if (companyBoughtThisTurn != null && (companyBoughtThisTurn != company || !company.getCurrentSpace().isNoBuyLimit())) {
      errMsg=LocalText.getText("String_Node_Str",playerName);
      break;
    }
    if (shares > from.getShare(company)) {
      errMsg=LocalText.getText("String_Node_Str",companyName,from.getName());
      break;
    }
    StockSpaceI currentSpace;
    if (from == ipo && company.hasParPrice()) {
      currentSpace=company.getStartSpace();
    }
 else {
      currentSpace=company.getCurrentSpace();
    }
    if (number > 1 && !currentSpace.isNoBuyLimit()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (!currentSpace.isNoCertLimit() && !mayPlayerBuyCertificate(currentPlayer,company,shares)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str",String.valueOf(gameManager.getPlayerCertificateLimit()));
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !mayPlayerBuyCompanyShare(currentPlayer,company,shares)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str");
      break;
    }
    price=currentSpace.getPrice();
    cash=shares * price;
    if (currentPlayer.getCash() < cash) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",playerName,shares,companyName,from.getName(),errMsg));
    return false;
  }
  moveStack.start(true);
  CashHolder priceRecipient=getSharePriceRecipient(cert,cash);
  if (number == 1) {
    ReportBuffer.add(LocalText.getText("String_Node_Str",playerName,shareUnit,companyName,from.getName(),Bank.format(cash)));
  }
 else {
    ReportBuffer.add(LocalText.getText("String_Node_Str",playerName,number,shareUnit,number * shareUnit,companyName,from.getName(),Bank.format(cash)));
  }
  ReportBuffer.getAllWaiting();
  PublicCertificateI cert2;
  for (int i=0; i < number; i++) {
    cert2=from.findCertificate(company,cert.getShares(),false);
    if (cert2 == null) {
      log.error("String_Node_Str" + companyName + "String_Node_Str"+ shareUnit+ "String_Node_Str"+ from.getName());
    }
    executeTradeCertificate(cert2,currentPlayer.getPortfolio(),cash,priceRecipient);
  }
  if (priceRecipient != from.getOwner()) {
    ReportBuffer.add(LocalText.getText("String_Node_Str",Bank.format(price * shares),priceRecipient.getName()));
  }
  companyBoughtThisTurnWrapper.set(company);
  hasActed.set(true);
  setPriority();
  company.checkPresidencyOnBuy(currentPlayer);
  if (!company.hasFloated())   checkFlotation(company);
  gameSpecificChecks(from,company);
  return true;
}

Fixed version (ground truth):
/** 
 * Buying one or more single or double-share certificates (more is sometimes possible)
 * @param player The player that wants to buy shares.
 * @param action The executed BuyCertificates action
 * @return True if the certificates could be bought. False indicates anerror.
 */
public boolean buyShares(String playerName,BuyCertificate action){
  PublicCertificateI cert=action.getCertificate();
  Portfolio from=cert.getPortfolio();
  String companyName=cert.getCompany().getName();
  int number=action.getNumberBought();
  int shares=number * cert.getShares();
  int shareUnit=cert.getShare();
  String errMsg=null;
  int price=0;
  int cost=0;
  PublicCompanyI company=null;
  currentPlayer=getCurrentPlayer();
  while (true) {
    if (!playerName.equals(currentPlayer.getName())) {
      errMsg=LocalText.getText("String_Node_Str",playerName);
      break;
    }
    company=companyManager.getPublicCompany(companyName);
    if (company == null) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (isSaleRecorded(currentPlayer,company)) {
      errMsg=LocalText.getText("String_Node_Str",currentPlayer.getName(),companyName);
      break;
    }
    if (!company.hasStarted()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    PublicCompanyI companyBoughtThisTurn=(PublicCompanyI)companyBoughtThisTurnWrapper.getObject();
    if (companyBoughtThisTurn != null && (companyBoughtThisTurn != company || !company.getCurrentSpace().isNoBuyLimit())) {
      errMsg=LocalText.getText("String_Node_Str",playerName);
      break;
    }
    if (shares > from.getShare(company)) {
      errMsg=LocalText.getText("String_Node_Str",companyName,from.getName());
      break;
    }
    StockSpaceI currentSpace;
    if (from == ipo && company.hasParPrice()) {
      currentSpace=company.getStartSpace();
    }
 else {
      currentSpace=company.getCurrentSpace();
    }
    if (number > 1 && !currentSpace.isNoBuyLimit()) {
      errMsg=LocalText.getText("String_Node_Str",companyName);
      break;
    }
    if (!currentSpace.isNoCertLimit() && !mayPlayerBuyCertificate(currentPlayer,company,shares)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str",String.valueOf(gameManager.getPlayerCertificateLimit()));
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !mayPlayerBuyCompanyShare(currentPlayer,company,shares)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str");
      break;
    }
    price=currentSpace.getPrice();
    cost=shares * price;
    if (currentPlayer.getCash() < cost) {
      errMsg=LocalText.getText("String_Node_Str");
      break;
    }
    break;
  }
  if (errMsg != null) {
    DisplayBuffer.add(LocalText.getText("String_Node_Str",playerName,shares,companyName,from.getName(),errMsg));
    return false;
  }
  moveStack.start(true);
  CashHolder priceRecipient=getSharePriceRecipient(cert,cost);
  if (number == 1) {
    ReportBuffer.add(LocalText.getText("String_Node_Str",playerName,shareUnit,companyName,from.getName(),Bank.format(cost)));
  }
 else {
    ReportBuffer.add(LocalText.getText("String_Node_Str",playerName,number,shareUnit,number * shareUnit,companyName,from.getName(),Bank.format(cost)));
  }
  ReportBuffer.getAllWaiting();
  PublicCertificateI cert2;
  for (int i=0; i < number; i++) {
    cert2=from.findCertificate(company,cert.getShares(),false);
    if (cert2 == null) {
      log.error("String_Node_Str" + companyName + "String_Node_Str"+ shareUnit+ "String_Node_Str"+ from.getName());
    }
    cert.moveTo(currentPlayer.getPortfolio());
  }
  new CashMove(currentPlayer,priceRecipient,cost);
  if (priceRecipient != from.getOwner()) {
    ReportBuffer.add(LocalText.getText("String_Node_Str",Bank.format(cost),priceRecipient.getName()));
  }
  companyBoughtThisTurnWrapper.set(company);
  hasActed.set(true);
  setPriority();
  company.checkPresidencyOnBuy(currentPlayer);
  if (!company.hasFloated())   checkFlotation(company);
  gameSpecificChecks(from,company);
  return true;
}