From: Florian Forster Date: Fri, 10 Sep 2010 09:26:38 +0000 (+0200) Subject: src/graph.c: Fix NULL-pointer dereference. X-Git-Tag: v4.0.0~14 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e44a32c44326ebe6ee10333138fabc337c067281;p=collection4.git src/graph.c: Fix NULL-pointer dereference. --- diff --git a/src/graph.c b/src/graph.c index fdbf713..deeb05a 100644 --- a/src/graph.c +++ b/src/graph.c @@ -662,10 +662,16 @@ int graph_def_to_json (const graph_config_t *cfg, /* {{{ */ yajl_gen_string_cast (handler, "select", strlen ("select")); ident_to_json (cfg->select, handler); - yajl_gen_string_cast (handler, "title", strlen ("title")); - yajl_gen_string_cast (handler, cfg->title, strlen (cfg->title)); - yajl_gen_string_cast (handler, "vertical_label", strlen ("vertical_label")); - yajl_gen_string_cast (handler, cfg->vertical_label, strlen (cfg->vertical_label)); + if (cfg->title != NULL) + { + yajl_gen_string_cast (handler, "title", strlen ("title")); + yajl_gen_string_cast (handler, cfg->title, strlen (cfg->title)); + } + if (cfg->vertical_label != NULL) + { + yajl_gen_string_cast (handler, "vertical_label", strlen ("vertical_label")); + yajl_gen_string_cast (handler, cfg->vertical_label, strlen (cfg->vertical_label)); + } yajl_gen_string_cast (handler, "show_zero", strlen ("show_zero")); yajl_gen_bool (handler, cfg->show_zero);