From 3960753fd6e7a5918ebc4222bd0149560e95b3f3 Mon Sep 17 00:00:00 2001 From: Jerome Kelleher Date: Fri, 19 Feb 2016 23:00:15 +0000 Subject: [PATCH] Fix allocation from stack bug. For large numbers of SNPs allocating from the stack caused a segfault. This fixes the issue by allocating from the heap with malloc. --- src/snp_sites.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/snp_sites.c b/src/snp_sites.c index 45b63126..68a22755 100644 --- a/src/snp_sites.c +++ b/src/snp_sites.c @@ -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++) {