From ccae870fc6f372a4f9057eb6e405168820789834 Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Mon, 6 Jan 2025 13:43:28 -0500 Subject: cdf: fixed realloc bug --- src/cdf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/cdf.c') diff --git a/src/cdf.c b/src/cdf.c index 2ab1d5c..45b8fb7 100644 --- a/src/cdf.c +++ b/src/cdf.c @@ -64,7 +64,7 @@ static void help() { static DistRecord *expand_array(DistRecord *records, size_t *capacity) { (*capacity) *= 2; - DistRecord *new = realloc(records, *capacity); + DistRecord *new = realloc(records, (*capacity*sizeof(DistRecord))); if (!new) { fprintf(stderr, "ERROR: Memory allocation failed\n"); return nullptr; @@ -125,13 +125,13 @@ static int print_data_fp(DistRecord *records, long double *freqs, size_t cnt) { if (ARG_REVERSE_CDF) { long double total_freq = 1.0; for (size_t i=0; i