From 0962c7f011b0e8e68eae23ae1842989b39b41603 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Tue, 24 Mar 2015 05:45:20 -0400 Subject: [PATCH 1/2] i3bar: check block text for NULL Add a null check to `full_text` and `short_text` for a block before setting the markup property to avoid a segfault. --- i3bar/src/child.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index 402e6351..a461c931 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -265,7 +265,9 @@ static int stdin_end_map(void *context) { } i3string_set_markup(new_block->full_text, new_block->is_markup); - i3string_set_markup(new_block->short_text, new_block->is_markup); + + if (new_block->short_text != NULL) + i3string_set_markup(new_block->short_text, new_block->is_markup); TAILQ_INSERT_TAIL(&statusline_buffer, new_block, blocks); return 1; From 177c03debd8f7329be8a173247a12b99dc5aa4c8 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Tue, 24 Mar 2015 06:00:26 -0400 Subject: [PATCH 2/2] i3bar: check `short_text` for NULL on dump Check `short_text` for NULL on statusline dump, since this value can be NULL when not given. Fixes a segfault in that case. --- i3bar/src/child.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3bar/src/child.c b/i3bar/src/child.c index a461c931..5347632a 100644 --- a/i3bar/src/child.c +++ b/i3bar/src/child.c @@ -286,7 +286,7 @@ static int stdin_end_array(void *context) { struct status_block *current; TAILQ_FOREACH(current, &statusline_head, blocks) { DLOG("full_text = %s\n", i3string_as_utf8(current->full_text)); - DLOG("short_text = %s\n", i3string_as_utf8(current->short_text)); + DLOG("short_text = %s\n", (current->short_text == NULL ? NULL : i3string_as_utf8(current->short_text))); DLOG("color = %s\n", current->color); } DLOG("end of dump\n");