Skip to content

Commit

Permalink
Prevent int overflow with +100k genotypes by casting to double. Fixes s…
Browse files Browse the repository at this point in the history
  • Loading branch information
pd3 committed Oct 1, 2018
1 parent 984adb8 commit cf72059
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/fill-tags.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void calc_hwe(args_t *args, int nref, int nalt, int nhet, float *p_hwe, float *p
double *probs = args->hwe_probs;

// start at midpoint
int mid = nrare * (nref + nalt - nrare) / (nref + nalt);
int mid = (double)nrare * (nref + nalt - nrare) / (nref + nalt);

// check to ensure that midpoint and rare alleles have same parity
if ( (nrare & 1) ^ (mid & 1) ) mid++;
Expand Down

0 comments on commit cf72059

Please sign in to comment.