]> git.ipfire.org Git - pakfire.git/commitdiff
cli: table: Prevent from adding columns after rows have been added
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 16:30:10 +0000 (16:30 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 16:30:10 +0000 (16:30 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/cli/lib/table.c

index f6c74a5f274c6af8eac73a59096f0fe0fc54754e..366f13c0c248b326085a0c19d17bc08e91c539e6 100644 (file)
@@ -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)