From: Michael Tremer Date: Tue, 1 Jul 2025 16:30:10 +0000 (+0000) Subject: cli: table: Prevent from adding columns after rows have been added X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=558bc579fb954513c83330742369127a60737501;p=pakfire.git cli: table: Prevent from adding columns after rows have been added Signed-off-by: Michael Tremer --- diff --git a/src/cli/lib/table.c b/src/cli/lib/table.c index f6c74a5f..366f13c0 100644 --- a/src/cli/lib/table.c +++ b/src/cli/lib/table.c @@ -146,6 +146,10 @@ void cli_table_free(cli_table* self) { int cli_table_add_col(cli_table* self, const char* name, cli_table_col_type type) { cli_table_col* col = NULL; + // Prevent from adding more columns after the first row has been added + if (!STAILQ_EMPTY(&self->rows)) + return -EPERM; + // Allocate a new col col = calloc(1, sizeof(*col)); if (!col)