Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
bcf_close crashes when it sees a nullptr
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthibault79 committed Aug 21, 2014
1 parent 2fd30b6 commit 1442e45
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion gamgee/multiple_variant_reader.h
Expand Up @@ -66,7 +66,8 @@ class MultipleVariantReader {
*/
~MultipleVariantReader() {
for (auto file_ptr : m_variant_files)
bcf_close(file_ptr);
if (file_ptr != nullptr)
bcf_close(file_ptr);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion gamgee/variant_reader.h
Expand Up @@ -124,7 +124,8 @@ class VariantReader {
* @brief closes the file stream if there is one (in case we are reading a variant file)
*/
~VariantReader() {
bcf_close(m_variant_file_ptr);
if (m_variant_file_ptr != nullptr)
bcf_close(m_variant_file_ptr);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion gamgee/variant_writer.cpp
Expand Up @@ -15,7 +15,8 @@ VariantWriter::VariantWriter(const VariantHeader& header, const std::string& out
}

VariantWriter::~VariantWriter() {
bcf_close(m_out_file);
if (m_out_file != nullptr)
bcf_close(m_out_file);
}

void VariantWriter::add_header(const VariantHeader& header) {
Expand Down

0 comments on commit 1442e45

Please sign in to comment.