aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjvech <jmvalenciae@unal.edu.co>2024-09-19 16:22:19 -0500
committerjvech <jmvalenciae@unal.edu.co>2024-09-19 16:22:19 -0500
commit3fc51ee0c8135d95ec422dadd6562bf97261a757 (patch)
tree2277eeae3f25c31c2e34fb4d7d11756ff182dfd0 /src
parent5e2295b87e00bce3c37ee4a2ba937b97f04307f1 (diff)
fix: wrong memory allocation on csv_read() fixed
Diffstat (limited to 'src')
-rw-r--r--src/parse.c8
1 files changed, 4 insertions, 4 deletions
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;
}
}
Feel free to download, copy and edit any repo