]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: (sample) check scols_line_set_data() return code [coverity scan]
authorKarel Zak <kzak@redhat.com>
Tue, 14 Jul 2020 09:36:23 +0000 (11:36 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jul 2020 09:36:23 +0000 (11:36 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/samples/fromfile.c

index 35d85489b5b3782f2f557808fd5a45cccf906fa3..64b3974dfae542f8c9e9972e9412a069d836622c 100644 (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);