From 39527b2075d45521fe74c1a80471607a39a0d877 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Thomas=20Wei=C3=9Fschuh?= Date: Sun, 24 Dec 2023 12:38:53 +0100 Subject: [PATCH] libsmartcols: (samples/fromfile) properly handle return value from getline() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Weißschuh --- libsmartcols/samples/fromfile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.47.3