From 558bc579fb954513c83330742369127a60737501 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 1 Jul 2025 16:30:10 +0000 Subject: [PATCH] cli: table: Prevent from adding columns after rows have been added Signed-off-by: Michael Tremer --- src/cli/lib/table.c | 4 ++++ 1 file changed, 4 insertions(+) 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) -- 2.47.3