Program: 173704
Project: 173704
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 cost=0;
  PublicCompanyI company=null;
  currentPlayer=getCurrentPlayer();
  while (true) {
    if (!playerName.equals(currentPlayer.getName())) {
      errMsg=LocalText.getText("String_Node_Str",playerName,currentPlayer.getName());
      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.isBuyable()) {
      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,number)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str",String.valueOf(gameManager.getPlayerCertificateLimit(currentPlayer)));
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !checkAgainstHoldLimit(currentPlayer,company,shares)) {
      errMsg=LocalText.getText("String_Node_Str",currentPlayer.getName(),GameDef.Parm.PLAYER_SHARE_LIMIT.defaultValueAsInt());
      break;
    }
    price=getBuyPrice(action,currentSpace);
    cost=shares * price / company.getShareUnitsForSharePrice();
    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;
}

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,currentPlayer.getName());
      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.isBuyable()) {
      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,number)) {
      errMsg=currentPlayer.getName() + LocalText.getText("String_Node_Str",String.valueOf(gameManager.getPlayerCertificateLimit(currentPlayer)));
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !checkAgainstHoldLimit(currentPlayer,company,shares)) {
      errMsg=LocalText.getText("String_Node_Str",currentPlayer.getName(),GameDef.Parm.PLAYER_SHARE_LIMIT.defaultValueAsInt());
      break;
    }
    price=getBuyPrice(action,currentSpace);
    cost=shares * price / company.getShareUnitsForSharePrice();
    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());
    }
    cert2.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;
}