From a29cf52bc6d5c1d3ff144ee7024bc92891a5fea6 Mon Sep 17 00:00:00 2001 From: David Wehr <dawehr@iastate.edu> Date: Sat, 18 Mar 2017 21:33:58 -0500 Subject: [PATCH] Made it so logging won't segfault/write to random memory if not initialized. --- quad/src/quad_app/log_data.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quad/src/quad_app/log_data.c b/quad/src/quad_app/log_data.c index 6c3f5c3e8..a72129f13 100644 --- a/quad/src/quad_app/log_data.c +++ b/quad/src/quad_app/log_data.c @@ -20,7 +20,7 @@ // Current index of the log array int arrayIndex = 0; // Size of the array -int arraySize = LOG_STARTING_SIZE; +int arraySize = 0; struct graph_tuple { // Tuple for int block_id; @@ -38,7 +38,7 @@ struct graph_tuple log_params[MAX_LOG_NUM]; size_t n_outputs; size_t n_params; -float* logArray; +float* logArray = NULL; int row_size; static char units_output_str[512] = {}; @@ -112,6 +112,8 @@ void initialize_logging(log_t* log_struct, parameter_t* ps) { logArray = malloc(needed_memory); if (!logArray) { // malloc failed arraySize = 0; + } else { + arraySize = LOG_STARTING_SIZE; } } -- GitLab