From 19b18693abd4ff06738056600130238425deabd4 Mon Sep 17 00:00:00 2001 From: Zilong-Li Date: Mon, 11 Mar 2024 11:27:05 +0100 Subject: [PATCH] make AddressSanitizer happy --- vcfpp.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcfpp.h b/vcfpp.h index 2c88310..5fbbc26 100644 --- a/vcfpp.h +++ b/vcfpp.h @@ -1575,10 +1575,12 @@ class BcfWriter } /// write a string to a vcf line - void writeLine(std::string vcfline) + void writeLine(const std::string & vcfline) { if(!isHeaderWritten && !writeHeader()) throw std::runtime_error("could not write header\n"); - kstring_t s = {vcfline.length(), vcfline.length(), &vcfline[0]}; // kstring + std::vector 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)