From 56ab7383fd5021da9e940253f5f722aab1828fe3 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 30 Jul 2014 17:22:39 +0200 Subject: [PATCH] Fix meshlink_get_all_nodes(). --- src/meshlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/meshlink.c b/src/meshlink.c index e4061f93..84bf4e10 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1023,12 +1023,12 @@ meshlink_node_t *meshlink_get_node(meshlink_handle_t *mesh, const char *name) { } meshlink_node_t **meshlink_get_all_nodes(meshlink_handle_t *mesh, meshlink_node_t **nodes, size_t *nmemb) { - if(!mesh || (nmemb && !nodes)) { + if(!mesh || !nmemb || (*nmemb && !nodes)) { meshlink_errno = MESHLINK_EINVAL; return NULL; } - meshlink_node_t **result, **p; + meshlink_node_t **result; //lock mesh->nodes pthread_mutex_lock(&(mesh->nodes_mutex)); @@ -1037,6 +1037,7 @@ meshlink_node_t **meshlink_get_all_nodes(meshlink_handle_t *mesh, meshlink_node_ result = realloc(nodes, *nmemb * sizeof *nodes); if(result) { + meshlink_node_t **p = result; for splay_each(node_t, n, mesh->nodes) *p++ = (meshlink_node_t *)n; } else { -- 2.39.5