From 4c155eb74b522f6e751ce7a484154fb467600174 Mon Sep 17 00:00:00 2001 From: pk910 Date: Sun, 2 Oct 2011 18:47:18 +0200 Subject: [PATCH] don't crash if a table field is NULL --- src/tools.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/tools.c b/src/tools.c index 0976848..43f27cd 100644 --- a/src/tools.c +++ b/src/tools.c @@ -179,8 +179,16 @@ char **table_end(struct Table *table) { if(!(table->col_flags[col] & TABLE_FLAG_COL_CONTENTS)) continue; if(table->col_flags[col] & TABLE_FLAG_COL_BOLD) table->table_lines[row][pos++] = '\002'; - for(i = 0; i < strlen(table->contents[row][col]); i++) { - table->table_lines[row][pos++] = table->contents[row][col][i]; + if(table->contents[row][col]) { + for(i = 0; i < strlen(table->contents[row][col]); i++) { + table->table_lines[row][pos++] = table->contents[row][col][i]; + } + } else { + i = 4; + table->table_lines[row][pos++] = 'N'; + table->table_lines[row][pos++] = 'U'; + table->table_lines[row][pos++] = 'L'; + table->table_lines[row][pos++] = 'L'; } if(col < table->width-1) { for(;i < table->maxwidth[col]; i++) { -- 2.20.1