diff --git a/common/string-table.c b/common/string-table.c index a75cac1b..dc9a5f74 100644 --- a/common/string-table.c +++ b/common/string-table.c @@ -18,6 +18,7 @@ #include #include #include +#include "common/messages.h" #include "common/string-table.h" /* @@ -54,6 +55,12 @@ char *table_vprintf(struct string_table *tab, unsigned int column, unsigned int if (!msg) return NULL; + if (column >= tab->ncols || row >= tab->nrows) { + error("attempt to write outside of table: col %u row %u fmt %s", + column, row, fmt); + return NULL; + } + if (tab->cells[idx]) free(tab->cells[idx]); tab->cells[idx] = msg;