Skip to content

Commit

Permalink
No overflows due to too long program names.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkskeller committed May 17, 2018
1 parent 7118543 commit 7cac3dd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Processor/Machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ Machine::Machine(int my_number, Names& playerNames,
exit(1);
}

sprintf(filename, "Programs/Schedules/%s.sch",progname.c_str());
cerr << "Opening file " << filename << endl;
inpf.open(filename);
if (inpf.fail()) { throw file_error("Missing '" + string(filename) + "'. Did you compile '" + progname + "'?"); }
string fname = "Programs/Schedules/" + progname + ".sch";
cerr << "Opening file " << fname << endl;
inpf.open(fname);
if (inpf.fail()) { throw file_error("Missing '" + fname + "'. Did you compile '" + progname + "'?"); }

int nprogs;
inpf >> nthreads;
Expand All @@ -95,10 +95,10 @@ Machine::Machine(int my_number, Names& playerNames,

// Load in the programs
progs.resize(nprogs,N.num_players());
char threadname[1024];
string threadname;
for (int i=0; i<nprogs; i++)
{ inpf >> threadname;
sprintf(filename,"Programs/Bytecode/%s.bc",threadname);
string filename = "Programs/Bytecode/" + threadname + ".bc";
cerr << "Loading program " << i << " from " << filename << endl;
ifstream pinp(filename);
if (pinp.fail()) { throw file_error(filename); }
Expand Down

0 comments on commit 7cac3dd

Please sign in to comment.