Commit 3ed77c7b authored by rdubner's avatar rdubner
Browse files

Eliminate SFIX segfault because of accessing tokens[0] when line was empty

parent b63c0006
...@@ -69,7 +69,7 @@ GetInputFileMappings(const VSTRING &input_file, const string &primary_file) ...@@ -69,7 +69,7 @@ GetInputFileMappings(const VSTRING &input_file, const string &primary_file)
s = Trim(s); s = Trim(s);
if( s.find(".file ") != string::npos) { if( s.find(".file ") != string::npos) {
VSTRING tokens = Split(s,"\t "); VSTRING tokens = Split(s,"\t ");
if( tokens[0] EQ ".file" AND isdigit(tokens[1][0]) ) { if( tokens.size() >= 3 AND tokens[0] EQ ".file" AND isdigit(tokens[1][0]) ) {
int nfile = stoi(tokens[1]); int nfile = stoi(tokens[1]);
string file = StripQuotes(tokens[2]); string file = StripQuotes(tokens[2]);
retval[file] = nfile; retval[file] = nfile;
...@@ -199,6 +199,9 @@ main(int argc, char **argv) ...@@ -199,6 +199,9 @@ main(int argc, char **argv)
ss << interject_line; ss << interject_line;
} }
VSTRING tokens = Split(Trim(input_file[i])," \t"); VSTRING tokens = Split(Trim(input_file[i])," \t");
if( tokens.empty() ) {
continue;
}
if( tokens[0] EQ ".file" ) { if( tokens[0] EQ ".file" ) {
// We've already taken care of all .file lines // We've already taken care of all .file lines
continue; continue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment