From 334145367a589792b49db6d0b84cc0e5bcaf2b1a Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 5 Dec 2012 10:54:46 +0100 Subject: [PATCH] src/action_show_graph_json.c: Fix memory corruption. --- src/action_show_graph_json.c | 6 +----- src/graph_list.h | 9 +++++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/action_show_graph_json.c b/src/action_show_graph_json.c index 0820fb0..6d6e156 100644 --- a/src/action_show_graph_json.c +++ b/src/action_show_graph_json.c @@ -48,7 +48,7 @@ static void write_callback (__attribute__((unused)) void *ctx, /* {{{ */ int action_show_graph_json (void) /* {{{ */ { - graph_config_t *cfg; + graph_config_t const *cfg; yajl_gen_config handler_config; yajl_gen handler; @@ -70,10 +70,7 @@ int action_show_graph_json (void) /* {{{ */ /* alloc functions = */ NULL, /* context = */ NULL); if (handler == NULL) - { - graph_destroy (cfg); return (-1); - } printf ("Content-Type: application/json\n"); @@ -87,7 +84,6 @@ int action_show_graph_json (void) /* {{{ */ status = graph_to_json (cfg, handler); - graph_destroy (cfg); yajl_gen_free (handler); return (status); diff --git a/src/graph_list.h b/src/graph_list.h index ff35f18..a2a61e6 100644 --- a/src/graph_list.h +++ b/src/graph_list.h @@ -38,6 +38,15 @@ int gl_config_submit (void); int gl_register_data_provider (const char *name, data_provider_t *p); +/* + * Returns the currently "selected" graph config. + * + * This function evaluates the HTTP query parameters and searches for a + * matching graph config structure. If a matching graph config is found, it + * will return a pointer to the graph config. Do *not* free or call + * graph_destroy() on this pointer. If no graph is found or parameters are + * incomplete, NULL is returned. + */ graph_config_t *gl_graph_get_selected (void); int gl_graph_get_all (_Bool include_dynamic, -- 2.30.2