don't crash if a table field is NULL
authorpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 16:47:18 +0000 (18:47 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 16:47:18 +0000 (18:47 +0200)
src/tools.c

index 097684855d8230a66cb21819ceb9240dce68a5cb..43f27cd35ac052148a7c39247aaeea4dbf78a0b2 100644 (file)
@@ -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++) {