From: Jérémie Galarneau Date: Fri, 7 Nov 2014 21:10:46 +0000 (-0500) Subject: Bypass 0 byte allocation when no domains are enabled X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=fa64dfb477cac50bb0b8a02fcf6b5a16a426d43b;p=lttng-tools.git Bypass 0 byte allocation when no domains are enabled Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index d882b074d..98e090539 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2388,6 +2388,10 @@ ssize_t cmd_list_domains(struct ltt_session *session, } } + if (!nb_dom) { + goto end; + } + *domains = zmalloc(nb_dom * sizeof(struct lttng_domain)); if (*domains == NULL) { ret = LTTNG_ERR_FATAL; @@ -2413,7 +2417,7 @@ ssize_t cmd_list_domains(struct ltt_session *session, } } } - +end: return nb_dom; error: diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 699d53323..c8484b93c 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3474,7 +3474,7 @@ skip_domain: case LTTNG_LIST_DOMAINS: { ssize_t nb_dom; - struct lttng_domain *domains; + struct lttng_domain *domains = NULL; nb_dom = cmd_list_domains(cmd_ctx->session, &domains); if (nb_dom < 0) {