From: Jonathan Rajotte Date: Mon, 3 Oct 2016 18:57:31 +0000 (-0400) Subject: Fix: test presence of override_attr before accessing its member X-Git-Tag: v2.9.0-rc1~10 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=49c360e815ad63e137ba9664f786c91df76d27b3;p=lttng-tools.git Fix: test presence of override_attr before accessing its member Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau --- diff --git a/src/lib/lttng-ctl/load.c b/src/lib/lttng-ctl/load.c index b396b7500..f89effed0 100644 --- a/src/lib/lttng-ctl/load.c +++ b/src/lib/lttng-ctl/load.c @@ -94,10 +94,12 @@ const char *lttng_load_session_attr_get_override_ctrl_url( { const char *ret = NULL; - if (attr && attr->override_attr->ctrl_url) { - ret = attr->raw_override_ctrl_url; + if (!attr || !attr->override_attr) { + goto end; } + ret = attr->raw_override_ctrl_url; +end: return ret; } @@ -106,10 +108,12 @@ const char *lttng_load_session_attr_get_override_data_url( { const char *ret = NULL; - if (attr && attr->override_attr->data_url) { - ret = attr->raw_override_data_url; + if (!attr || !attr->override_attr) { + goto end; } + ret = attr->raw_override_data_url; +end: return ret; } @@ -118,12 +122,16 @@ const char *lttng_load_session_attr_get_override_url( { const char *ret = NULL; - if (attr && (attr->override_attr->path_url || + if (!attr || !attr->override_attr) { + goto end; + } + + if ((attr->override_attr->path_url || (attr->override_attr->ctrl_url && attr->override_attr->data_url))) { ret = attr->raw_override_url; } - +end: return ret; }