From 05e547e7ee479fa2c3ca5bc9d2eb57bc8a07bdb8 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 27 Jan 2012 12:37:45 -0800 Subject: table: Avoid segmentation fault when printing an empty cell in JSON format. Signed-off-by: Ben Pfaff --- lib/table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/table.c b/lib/table.c index ff11e781..537fae97 100644 --- a/lib/table.c +++ b/lib/table.c @@ -480,8 +480,10 @@ table_print_json__(const struct table *table, const struct table_style *style) const struct cell *cell = table_cell__(table, y, x); if (cell->text) { json_array_add(row, json_string_create(cell->text)); - } else { + } else if (cell->json) { json_array_add(row, json_clone(cell->json)); + } else { + json_array_add(row, json_null_create()); } } json_array_add(data, row); -- cgit v1.2.3