libsmartcols: (sample) check scols_line_set_data() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-07-14 11:36:23 +02:00
parent e19e522df0
commit 8aedaf592e
1 changed files with 3 additions and 2 deletions

View File

@ -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);