Skip to content

Commit 1860cb6

Browse files
sirus20x6pd3
authored andcommitted
Fix memset bugs in bam2bcf_iaux.c and bam2bcf.c
In bam2bcf_iaux.c, the memset after the first pass was zeroing `aux` (the nucleotide frequency counts) instead of `cns` (the consensus output buffer). This caused the consensus-building loop to see all-zero counts and produce 'N' for every position, discarding all insertion data. In bam2bcf.c, remove a duplicate memset(call->SCR, ...) that was a copy-paste error (two identical lines in a row).
1 parent 0486a68 commit 1860cb6

2 files changed

Lines changed: 1 addition & 2 deletions

File tree

bam2bcf.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ void bcf_callaux_clean(bcf_callaux_t *bca, bcf_call_t *call)
211211
if ( call->ADF ) memset(call->ADF,0,sizeof(int32_t)*(call->n+1)*B2B_MAX_ALLELES);
212212
if ( call->ADR ) memset(call->ADR,0,sizeof(int32_t)*(call->n+1)*B2B_MAX_ALLELES);
213213
if ( call->SCR ) memset(call->SCR,0,sizeof(*call->SCR)*(call->n+1));
214-
if ( call->SCR ) memset(call->SCR,0,sizeof(*call->SCR)*(call->n+1));
215214
if ( bca->fmt_flag&B2B_FMT_NMBZ )
216215
{
217216
memset(call->ref_nm,0,sizeof(*call->ref_nm)*(call->n+1)*B2B_N_NM);

bam2bcf_iaux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int iaux_init_ins_types(indel_aux_t *iaux)
228228
iaux->minscns = ncns;
229229
}
230230
else cns = iaux->inscns;
231-
memset(aux,0,ncns*sizeof(*cns));
231+
memset(cns,0,ncns*sizeof(*cns));
232232

233233
// use the majority rule to construct the consensus
234234
for (t=0; t<iaux->ntypes; t++)

0 commit comments

Comments
 (0)