Skip to content

Commit

Permalink
Fix an issue where fclose may be called before other threads are done…
Browse files Browse the repository at this point in the history
… with file
  • Loading branch information
ch4rr0 committed Feb 4, 2020
1 parent 8a12282 commit 0bedd44
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,6 +1192,8 @@ const uint8_t BAMPatternSource::EOF_MARKER[] = {

uint16_t BAMPatternSource::nextBGZFBlockFromFile(BGZF& b) {
if (fread(&b.hdr, sizeof(b.hdr), 1, fp_) != 1) {
if (feof(fp_))
return 0;
std::cerr << "Error while reading BAM header" << std::endl;
exit(EXIT_FAILURE);
}
Expand All @@ -1204,7 +1206,6 @@ uint16_t BAMPatternSource::nextBGZFBlockFromFile(BGZF& b) {
memcmp(EOF_MARKER + sizeof(b.hdr), extra, 6 /* sizeof BAM subfield */) == 0)
{
delete[] extra;
fclose(fp_);
return 0;
}
uint16_t bsize = 0;
Expand Down

0 comments on commit 0bedd44

Please sign in to comment.