From c531b86e6b5ebc63bc350b55a082b2d58ca7105b Mon Sep 17 00:00:00 2001 From: Niklas Hofmann Date: Thu, 14 Aug 2014 10:18:52 +0200 Subject: [PATCH] bugfix handle case where count(edges) = 0 --- src/devtools.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/devtools.c b/src/devtools.c index 9c017307..d287f3c9 100644 --- a/src/devtools.c +++ b/src/devtools.c @@ -54,7 +54,7 @@ bool devtool_export_json_all_edges_state(meshlink_handle_t *mesh, FILE* stream) meshlink_node_t **nodes = meshlink_get_all_nodes(mesh, NULL, &node_count); meshlink_edge_t **edges = meshlink_get_all_edges_state(mesh, NULL, &edge_count); - if(!nodes || !edges) + if((!nodes && node_count != 0) || (!edges && edge_count != 0)) { goto fail; } // export begin @@ -145,12 +145,14 @@ fail: done: - free(nodes); + if(nodes) + { free(nodes); } for(size_t i = 0; edges && i < edge_count; ++i) { free(edges[i]); } - free(edges); + if(nodes) + { free(edges); } pthread_mutex_unlock(&(mesh->mesh_mutex)); -- 2.39.5