Skip to content

Commit 17d21f3

Browse files
fixing a crash when the chromosome name only has one word
1 parent 9a070f4 commit 17d21f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

smithlab_os.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,11 @@ read_fasta_file_short_names(const string &filename,
390390
string line;
391391
while (getline(in, line)) {
392392
if (line[0] == '>') {
393-
names.push_back(string(begin(line) + 1,
393+
const auto first_space = line.find_first_of(" \t", 1);
394+
if (first_space == string::npos)
395+
names.push_back(line.substr(1));
396+
else
397+
names.push_back(string(begin(line) + 1,
394398
begin(line) + line.find_first_of(" \t", 1)));
395399
sequences.push_back(string());
396400
}

0 commit comments

Comments
 (0)