From 8aedaf592ed7be47adbc4a33eaf7be19598b21cf Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 14 Jul 2020 11:36:23 +0200 Subject: [PATCH] libsmartcols: (sample) check scols_line_set_data() return code [coverity scan] Signed-off-by: Karel Zak --- libsmartcols/samples/fromfile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsmartcols/samples/fromfile.c b/libsmartcols/samples/fromfile.c index 35d85489b5..64b3974dfa 100644 --- a/libsmartcols/samples/fromfile.c +++ b/libsmartcols/samples/fromfile.c @@ -134,6 +134,7 @@ static int parse_column_data(FILE *f, struct libscols_table *tb, int col) size_t len = 0, nlines = 0; int i; char *str = NULL; + int rc; while ((i = getline(&str, &len, f)) != -1) { @@ -151,8 +152,8 @@ static int parse_column_data(FILE *f, struct libscols_table *tb, int col) if (!ln) break; - if (str && *str) - scols_line_set_data(ln, col, str); + if (str && *str && scols_line_set_data(ln, col, str) != 0) + err(EXIT_FAILURE, "failed to add output data"); } free(str); -- 2.47.2