Skip to content

Commit

Permalink
Fix warnings identified with -fsanitize=address
Browse files Browse the repository at this point in the history
  • Loading branch information
pd3 committed Jul 17, 2018
1 parent c3c5569 commit 26b2845
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion bam_sample.c
@@ -1,7 +1,7 @@
/* bam_sample.c -- group data by sample.
Copyright (C) 2010, 2011 Broad Institute.
Copyright (C) 2013, 2016 Genome Research Ltd.
Copyright (C) 2013, 2016-2018 Genome Research Ltd.
Author: Heng Li <lh3@sanger.ac.uk>, Petr Danecek <pd3@sanger.ac.uk>
Expand Down Expand Up @@ -238,6 +238,7 @@ int bam_smpl_add_bam(bam_smpl_t *bsmpl, char *bam_hdr, const char *fname)
{
// no suitable read group is available in this bam: ignore the whole file.
free(file->fname);
if ( file->rg2idx ) khash_str2int_destroy_free(file->rg2idx);
bsmpl->nfiles--;
return -1;
}
Expand Down
8 changes: 4 additions & 4 deletions csq.c
Expand Up @@ -3376,7 +3376,7 @@ int test_cds(args_t *args, bcf1_t *rec)
fprintf(args->out,"LOG\tWarning: Skipping overlapping variants at %s:%d\t%s>%s\n", chr,rec->pos+1,rec->d.allele[0],rec->d.allele[1]);
}
else ret = 1; // prevent reporting as intron in test_tscript
free(child);
hap_destroy(child);
continue;
}
if ( child->type==HAP_SSS )
Expand All @@ -3390,7 +3390,7 @@ int test_cds(args_t *args, bcf1_t *rec)
csq.type.gene = tr->gene->name;
csq.type.type = child->csq;
csq_stage(args, &csq, rec);
free(child);
hap_destroy(child);
ret = 1;
continue;
}
Expand Down Expand Up @@ -3475,7 +3475,7 @@ int test_cds(args_t *args, bcf1_t *rec)
fprintf(args->out,"LOG\tWarning: Skipping overlapping variants at %s:%d, sample %s\t%s>%s\n",
chr,rec->pos+1,args->hdr->samples[args->smpl->idx[ismpl]],rec->d.allele[0],rec->d.allele[ial]);
}
free(child);
hap_destroy(child);
continue;
}
if ( child->type==HAP_SSS )
Expand All @@ -3489,7 +3489,7 @@ int test_cds(args_t *args, bcf1_t *rec)
csq.type.gene = tr->gene->name;
csq.type.type = child->csq;
csq_stage(args, &csq, rec);
free(child);
hap_destroy(child);
continue;
}
if ( parent->cur_rec!=rec )
Expand Down
20 changes: 10 additions & 10 deletions vcfroh.c
@@ -1,6 +1,6 @@
/* vcfroh.c -- HMM model for detecting runs of autozygosity.
Copyright (C) 2013-2017 Genome Research Ltd.
Copyright (C) 2013-2018 Genome Research Ltd.
Author: Petr Danecek <pd3@sanger.ac.uk>
Expand Down Expand Up @@ -749,9 +749,9 @@ int estimate_AF_from_PL(args_t *args, bcf_fmt_t *fmt_pl, int ial, double *alt_fr
if ( p[irr]<0 || p[ira]<0 || p[iaa]<0 ) continue; /* missing value */ \
if ( p[irr]==p[ira] && p[irr]==p[iaa] ) continue; /* all values are the same */ \
double prob[3], norm = 0; \
prob[0] = p[irr] < (type_t)256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
prob[1] = p[ira] < (type_t)256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
prob[2] = p[iaa] < (type_t)256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
prob[0] = p[irr] < 256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
prob[1] = p[ira] < 256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
prob[2] = p[iaa] < 256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
for (j=0; j<3; j++) norm += prob[j]; \
for (j=0; j<3; j++) prob[j] /= norm; \
af += 0.5*prob[1] + prob[2]; \
Expand Down Expand Up @@ -779,9 +779,9 @@ int estimate_AF_from_PL(args_t *args, bcf_fmt_t *fmt_pl, int ial, double *alt_fr
if ( p[irr]<0 || p[ira]<0 || p[iaa]<0 ) continue; /* missing value */ \
if ( p[irr]==p[ira] && p[irr]==p[iaa] ) continue; /* all values are the same */ \
double prob[3], norm = 0; \
prob[0] = p[irr] < (type_t)256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
prob[1] = p[ira] < (type_t)256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
prob[2] = p[iaa] < (type_t)256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
prob[0] = p[irr] < 256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
prob[1] = p[ira] < 256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
prob[2] = p[iaa] < 256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
for (j=0; j<3; j++) norm += prob[j]; \
for (j=0; j<3; j++) prob[j] /= norm; \
af += 0.5*prob[1] + prob[2]; \
Expand Down Expand Up @@ -926,9 +926,9 @@ int process_line(args_t *args, bcf1_t *line, int ial)
type_t *p = (type_t*)fmt_pl->p + fmt_pl->n*ismpl; \
if ( p[irr]<0 || p[ira]<0 || p[iaa]<0 ) continue; /* missing value */ \
if ( p[irr]==p[ira] && p[irr]==p[iaa] ) continue; /* all values are the same */ \
pdg[0] = p[irr] < (type_t)256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
pdg[1] = p[ira] < (type_t)256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
pdg[2] = p[iaa] < (type_t)256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
pdg[0] = p[irr] < 256 ? args->pl2p[ p[irr] ] : args->pl2p[255]; \
pdg[1] = p[ira] < 256 ? args->pl2p[ p[ira] ] : args->pl2p[255]; \
pdg[2] = p[iaa] < 256 ? args->pl2p[ p[iaa] ] : args->pl2p[255]; \
}
switch (fmt_pl->type) {
case BCF_BT_INT8: BRANCH(int8_t); break;
Expand Down

0 comments on commit 26b2845

Please sign in to comment.