From: Gerhard Sittig Date: Fri, 9 Jun 2017 21:10:40 +0000 (+0200) Subject: input/csv: Eliminate remaining memory leaks in error paths X-Git-Tag: libsigrok-0.5.0~9 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2355d2291925ace0bd9c85b21f2ce7e2c6606c7f;p=libsigrok.git input/csv: Eliminate remaining memory leaks in error paths When the processing of columns of text lines detected errors, the loop was aborted and the routine was left, but allocated resources were not freed. Fix the remaining memory leaks in the error code paths. --- diff --git a/src/input/csv.c b/src/input/csv.c index ad18e322..000599a8 100644 --- a/src/input/csv.c +++ b/src/input/csv.c @@ -784,6 +784,7 @@ static int process_buffer(struct sr_input *in, gboolean is_eof) columns = parse_line(line, inc, max_columns); if (!columns) { sr_err("Error while parsing line %zu.", inc->line_number); + g_strfreev(lines); return SR_ERR; } num_columns = g_strv_length(columns); @@ -791,6 +792,7 @@ static int process_buffer(struct sr_input *in, gboolean is_eof) sr_err("Column %u in line %zu is out of bounds.", inc->first_column, inc->line_number); g_strfreev(columns); + g_strfreev(lines); return SR_ERR; } /* @@ -801,6 +803,7 @@ static int process_buffer(struct sr_input *in, gboolean is_eof) sr_err("Not enough columns for desired number of channels in line %zu.", inc->line_number); g_strfreev(columns); + g_strfreev(lines); return SR_ERR; } @@ -810,6 +813,7 @@ static int process_buffer(struct sr_input *in, gboolean is_eof) ret = parse_single_column(columns[0], inc); if (ret != SR_OK) { g_strfreev(columns); + g_strfreev(lines); return SR_ERR; } @@ -818,6 +822,7 @@ static int process_buffer(struct sr_input *in, gboolean is_eof) if (ret != SR_OK) { sr_err("Sending samples failed."); g_strfreev(columns); + g_strfreev(lines); return SR_ERR; }