Skip to content

Commit

Permalink
Fix allocation from stack bug.
Browse files Browse the repository at this point in the history
For large numbers of SNPs allocating from the stack caused a segfault.
This fixes the issue by allocating from the heap with malloc.
  • Loading branch information
jeromekelleher committed Feb 19, 2016
1 parent c5c8dec commit 3960753
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/snp_sites.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int generate_snp_sites(char filename[], int exclude_gaps, char suffix[])
internal_nodes[a] = 0;
}

char* bases_for_snps[number_of_snps];
char** bases_for_snps = malloc(number_of_snps * sizeof(char *));

for(i = 0; i < number_of_snps; i++)
{
Expand Down

0 comments on commit 3960753

Please sign in to comment.