From: Thomas Weißschuh Date: Sun, 24 Dec 2023 11:38:53 +0000 (+0100) Subject: libsmartcols: (samples/fromfile) properly handle return value from getline() X-Git-Tag: v2.40-rc1~84^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39527b2075d45521fe74c1a80471607a39a0d877;p=thirdparty%2Futil-linux.git libsmartcols: (samples/fromfile) properly handle return value from getline() Signed-off-by: Thomas Weißschuh --- diff --git a/libsmartcols/samples/fromfile.c b/libsmartcols/samples/fromfile.c index f627df872d..cf77cc4766 100644 --- a/libsmartcols/samples/fromfile.c +++ b/libsmartcols/samples/fromfile.c @@ -44,7 +44,7 @@ static struct libscols_column *parse_column(const char *path) static int parse_column_data(FILE *f, struct libscols_table *tb, int col) { size_t len = 0, nlines = 0; - int i; + ssize_t i; char *str = NULL, *p; while ((i = getline(&str, &len, f)) != -1) { @@ -64,7 +64,7 @@ static int parse_column_data(FILE *f, struct libscols_table *tb, int col) /* convert \x?? to real bytes */ if (strstr(str, "\\x")) { struct libscols_cell *ce = scols_line_get_cell(ln, col); - size_t sz = len + 1; + size_t sz = i + 1; char *buf = xcalloc(1, sz); sz = unhexmangle_to_buffer(str, buf, sz);