Program: 173850
Project: 173850
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 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.
 * @param unit The number of share units in each certificate to buy (e.g. value is 2 for 20% Badische or 10% Preussische non-president certificates in 1835).
 * @return True if the certificates could be bought. False indicates anerror. TODO Usage of 'unit' argument.
 */
public boolean buyShare(String playerName,Portfolio from,String companyName,int shares,int unit){
  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;
    }
    company=companyMgr.getPublicCompany(companyName);
    if (company == null) {
      errMsg="String_Node_Str";
      break;
    }
    if (isSaleRecorded(currentPlayer,company)) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyName+ "String_Node_Str";
      break;
    }
    if (!company.hasStarted()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (companyBoughtThisTurn != null && (companyBoughtThisTurn != company || !company.getCurrentPrice().isNoBuyLimit())) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyBoughtThisTurn.getName()+ "String_Node_Str";
      break;
    }
    if (shares > from.ownsShare(company)) {
      errMsg=companyName + "String_Node_Str";
      break;
    }
    StockSpaceI currentSpace;
    if (from == ipo && company.hasParPrice()) {
      currentSpace=company.getParPrice();
    }
 else {
      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);
    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");
    currentPlayer.buy(cert,price * cert.getShares());
  }
  companyBoughtThisTurn=company;
  hasPassed=false;
  setPriority();
  if (from == ipo)   company.checkFlotation();
  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 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.
 * @param unit The number of share units in each certificate to buy (e.g. value is 2 for 20% Badische or 10% Preussische non-president certificates in 1835).
 * @return True if the certificates could be bought. False indicates anerror. TODO Usage of 'unit' argument.
 */
public boolean buyShare(String playerName,Portfolio from,String companyName,int shares,int unit){
  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;
    }
    company=companyMgr.getPublicCompany(companyName);
    if (company == null) {
      errMsg="String_Node_Str";
      break;
    }
    if (isSaleRecorded(currentPlayer,company)) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyName+ "String_Node_Str";
      break;
    }
    if (!company.hasStarted()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (companyBoughtThisTurn != null && (companyBoughtThisTurn != company || !company.getCurrentPrice().isNoBuyLimit())) {
      errMsg=currentPlayer.getName() + "String_Node_Str" + companyBoughtThisTurn.getName()+ "String_Node_Str";
      break;
    }
    if (shares > from.ownsShare(company)) {
      errMsg=companyName + "String_Node_Str";
      break;
    }
    StockSpaceI currentSpace;
    if (from == ipo && company.hasParPrice()) {
      currentSpace=company.getParPrice();
    }
 else {
      currentSpace=company.getCurrentPrice();
    }
    if (shares > 1 && !currentSpace.isNoBuyLimit()) {
      errMsg="String_Node_Str" + companyName + "String_Node_Str";
      break;
    }
    if (!currentSpace.isNoCertLimit() && !currentPlayer.mayBuyCertificate(company,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);
    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");
    currentPlayer.buy(cert,price * cert.getShares());
  }
  companyBoughtThisTurn=company;
  hasPassed=false;
  setPriority();
  if (from == ipo)   company.checkFlotation();
  return true;
}