Program: 173926
Project: 173926
Buggy source:
/** 
 * Buying one or more shares (more is sometimes possible)
 * @param player The player that wants to buy shares.
 * @param portfolio The portfolio from which to buy shares. 
 * @param company The company of which to buy shares.
 * @param shares The number of shares to buy.
 * @return True if the company could be started. False indicates an error.TODO Does not yet cater for double non-president shares as in 1835. 
 * @return False if an error is found.
 */
public boolean buyShare(String playerName,Portfolio from,String companyName,int shares){
  String errMsg=null;
  int price=0;
  PublicCompanyI company=null;
  currentPlayer=GameManager.getCurrentPlayer();
  while (true) {
    if (!playerName.equals(currentPlayer.getName())) {
      errMsg="String_Node_Str" + playerName;
      break;
    }
    if (hasBoughtThisTurn) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    if (playersThatSoldThisRound.containsKey(currentPlayer) && ((HashMap)playersThatSoldThisRound.get(currentPlayer)).containsKey(companyName)) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyName+ "String_Node_Str";
      break;
    }
    company=companyMgr.getPublicCompany(companyName);
    if (company == null) {
      errMsg="String_Node_Str";
      break;
    }
    if (!company.hasStarted()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (shares > from.countShares(company)) {
      errMsg=companyName + "String_Node_Str";
      break;
    }
    StockSpaceI currentSpace=company.getCurrentPrice();
    if (shares > 1 && !currentSpace.isNoBuyLimit()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (!currentSpace.isNoCertLimit() && !currentPlayer.mayBuyCertificates(shares)) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !currentPlayer.mayBuyCompanyShare(company,shares)) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    price=currentSpace.getPrice();
    if (currentPlayer.getCash() < shares * price) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    break;
  }
  if (errMsg != null) {
    Log.error(playerName + "String_Node_Str" + shares+ "String_Node_Str"+ companyName+ "String_Node_Str"+ from.getName()+ "String_Node_Str"+ errMsg);
    return false;
  }
  PublicCertificateI cert;
  for (int i=0; i < shares; i++) {
    cert=from.findCertificate(company,false);
    currentPlayer.getPortfolio().buyCertificate(cert,from,price * cert.getShares());
    Log.write(playerName + "String_Node_Str" + shares+ "String_Node_Str"+ cert.getShare()+ "String_Node_Str"+ companyName+ "String_Node_Str"+ from.getName()+ "String_Node_Str"+ Bank.format(shares * price)+ "String_Node_Str");
  }
  hasBoughtThisTurn=true;
  hasPassed=false;
  setPriority();
  if (from == ipo && !company.hasFloated() && from.countShares(company) <= (100 - company.getFloatPercentage())) {
    company.setFloated(10 * price);
    Log.write(companyName + "String_Node_Str" + Bank.format(company.getCash()));
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Buying one or more shares (more is sometimes possible)
 * @param player The player that wants to buy shares.
 * @param portfolio The portfolio from which to buy shares. 
 * @param company The company of which to buy shares.
 * @param shares The number of shares to buy.
 * @return True if the company could be started. False indicates an error.TODO Does not yet cater for double non-president shares as in 1835. 
 * @return False if an error is found.
 */
public boolean buyShare(String playerName,Portfolio from,String companyName,int shares){
  String errMsg=null;
  int price=0;
  PublicCompanyI company=null;
  currentPlayer=GameManager.getCurrentPlayer();
  while (true) {
    if (!playerName.equals(currentPlayer.getName())) {
      errMsg="String_Node_Str" + playerName;
      break;
    }
    if (hasBoughtThisTurn) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    if (playersThatSoldThisRound.containsKey(currentPlayer) && ((HashMap)playersThatSoldThisRound.get(currentPlayer)).containsKey(companyName)) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyName+ "String_Node_Str";
      break;
    }
    company=companyMgr.getPublicCompany(companyName);
    if (company == null) {
      errMsg="String_Node_Str";
      break;
    }
    if (!company.hasStarted()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (shares > from.ownsShare(company)) {
      errMsg=companyName + "String_Node_Str";
      break;
    }
    StockSpaceI currentSpace=company.getCurrentPrice();
    if (shares > 1 && !currentSpace.isNoBuyLimit()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (!currentSpace.isNoCertLimit() && !currentPlayer.mayBuyCertificates(shares)) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    if (!currentSpace.isNoHoldLimit() && !currentPlayer.mayBuyCompanyShare(company,shares)) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    price=currentSpace.getPrice();
    if (currentPlayer.getCash() < shares * price) {
      errMsg=currentPlayer.getName() + "String_Node_Str";
      break;
    }
    break;
  }
  if (errMsg != null) {
    Log.error(playerName + "String_Node_Str" + shares+ "String_Node_Str"+ companyName+ "String_Node_Str"+ from.getName()+ "String_Node_Str"+ errMsg);
    return false;
  }
  PublicCertificateI cert;
  for (int i=0; i < shares; i++) {
    cert=from.findCertificate(company,false);
    currentPlayer.getPortfolio().buyCertificate(cert,from,price * cert.getShares());
    Log.write(playerName + "String_Node_Str" + shares+ "String_Node_Str"+ cert.getShare()+ "String_Node_Str"+ companyName+ "String_Node_Str"+ from.getName()+ "String_Node_Str"+ Bank.format(shares * price)+ "String_Node_Str");
  }
  hasBoughtThisTurn=true;
  hasPassed=false;
  setPriority();
  if (from == ipo && !company.hasFloated() && from.ownsShare(company) <= (100 - company.getFloatPercentage())) {
    company.setFloated(10 * price);
    Log.write(companyName + "String_Node_Str" + Bank.format(company.getCash()));
  }
  return true;
}