From 3fc51ee0c8135d95ec422dadd6562bf97261a757 Mon Sep 17 00:00:00 2001 From: jvech Date: Thu, 19 Sep 2024 16:22:19 -0500 Subject: fix: wrong memory allocation on csv_read() fixed --- src/parse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/parse.c') diff --git a/src/parse.c b/src/parse.c index 6aa5563..d11d006 100644 --- a/src/parse.c +++ b/src/parse.c @@ -429,8 +429,8 @@ void csv_read( n_values_buffer = n_in_keys + n_out_keys; values_buffer = ecalloc(n_values_buffer, sizeof(char *)); - in_indexes = ecalloc(n_in_keys, sizeof(char)); - out_indexes = ecalloc(n_out_keys, sizeof(char)); + in_indexes = ecalloc(n_in_keys, sizeof(size_t)); + out_indexes = ecalloc(n_out_keys, sizeof(size_t)); if (fp == NULL) die("csv_read() Error:"); @@ -486,12 +486,12 @@ void csv_read( for (i = 0; i < n_in_keys; i++) { key_index = util_get_key_index(in_keys[i], values_buffer, n_values_buffer); - in_indexes[i] = has_header ? key_index : i; + in_indexes[i] = has_header ? (size_t)key_index : i; } for (i = 0; i < n_out_keys && read_output; i++) { key_index = util_get_key_index(out_keys[i], values_buffer, n_values_buffer); - out_indexes[i] = has_header ? key_index : i + n_in_keys; + out_indexes[i] = has_header ? (size_t)key_index : i + n_in_keys; } } -- cgit v1.2.3-70-g09d2