]> git.sur5r.net Git - i3/i3/commitdiff
i3bar: Don’t crash when full_text is missing or null in the JSON input (Thanks fernan...
authorMichael Stapelberg <michael@stapelberg.de>
Sat, 12 May 2012 06:23:37 +0000 (08:23 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Sat, 12 May 2012 06:23:51 +0000 (08:23 +0200)
i3bar/src/child.c

index 0b6f07df34ff06ecf61f40de367587b230588831..c2be484ba9210d1f71425025306c0ba4a60883c7 100644 (file)
@@ -128,6 +128,10 @@ static int stdin_end_map(void *context) {
     parser_ctx *ctx = context;
     struct status_block *new_block = smalloc(sizeof(struct status_block));
     memcpy(new_block, &(ctx->block), sizeof(struct status_block));
+    /* Ensure we have a full_text set, so that when it is missing (or null),
+     * i3bar doesn’t crash and the user gets an annoying message. */
+    if (!new_block->full_text)
+        new_block->full_text = sstrdup("SPEC VIOLATION (null)");
     TAILQ_INSERT_TAIL(&statusline_head, new_block, blocks);
     return 1;
 }