Skip to content

Commit

Permalink
make AddressSanitizer happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zilong-Li committed Mar 11, 2024
1 parent c1a7a8a commit 74cfb84
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Linux

on:
push:
branches: [ main, dev ]
branches: [ main, doc ]
pull_request:
branches: [ main ]

Expand Down Expand Up @@ -35,5 +35,6 @@ jobs:
run: |
cd test
make
export ASAN_OPTIONS=alloc_dealloc_mismatch=0
make test
# find . -name "*.bin" -exec '{}' --success ';'
3 changes: 2 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# detect OS architecture and add flags
CXX = g++
CXXFLAGS = -std=c++11 -g -Wall -fsanitize=address
# CXXFLAGS = -std=c++11 -Wall -g -fsanitize=address
CXXFLAGS = -std=c++11 -Wall
HTSINC = /usr/local/include
HTSLIB = /usr/local/lib
LDFLAGS = -L$(HTSLIB) -Wl,-rpath,$(HTSLIB)
Expand Down
9 changes: 3 additions & 6 deletions vcfpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,6 @@ class BcfWriter
std::shared_ptr<htsFile> fp; // hts file
std::shared_ptr<bcf1_t> b = std::shared_ptr<bcf1_t>(bcf_init(), variant_close()); // variant
int ret;
kstring_t s = {0, 0, NULL}; // kstring
bool isHeaderWritten = false;

public:
Expand Down Expand Up @@ -1579,11 +1578,9 @@ class BcfWriter
void writeLine(const std::string & vcfline)
{
if(!isHeaderWritten && !writeHeader()) throw std::runtime_error("could not write header\n");
std::vector<char> line(vcfline.begin(), vcfline.end());
line.push_back('\0'); // don't forget string has no \0;
s.s = &line[0];
s.l = vcfline.length();
s.m = vcfline.length();
std::vector<char> str(vcfline.begin(), vcfline.end());
str.push_back('\0'); // don't forget string has no \0;
kstring_t s = {vcfline.length(), vcfline.length(), &str[0]}; // kstring
ret = vcf_parse(&s, header.hdr, b.get());
if(ret > 0) throw std::runtime_error("error parsing: " + vcfline + "\n");
if(b->errcode == BCF_ERR_CTG_UNDEF)
Expand Down

0 comments on commit 74cfb84

Please sign in to comment.