From 05932fe8da075311149e8b2608a70fc0e3be3187 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 26 Feb 2021 13:58:16 -0500 Subject: [PATCH] Clean-up: uri_parse_str_urls: assert on invalid uri_parse() return values MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit uri_parse() can only ever return values [-1, 2] and callers only handle those values. This causes Coverity to report possible leaks and other errors when analyzing callers. Signed-off-by: Jérémie Galarneau Change-Id: Ida29691420228f0425cc908641bcd85208d66236 --- src/common/uri.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/common/uri.c b/src/common/uri.c index 0638aebd9..0f89468c5 100644 --- a/src/common/uri.c +++ b/src/common/uri.c @@ -577,6 +577,9 @@ ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url, goto parse_error; } + /* 1 and 2 are the only expected values on success. */ + assert(size_ctrl == 1 || size_ctrl == 2); + /* At this point, we know there is at least one URI in the array */ set_default_uri_attr(&ctrl_uris[0], LTTNG_STREAM_CONTROL); @@ -614,6 +617,9 @@ ssize_t uri_parse_str_urls(const char *ctrl_url, const char *data_url, } else if (size_data == 2) { ERR("Data URL can not be set with the net[4|6]:// protocol"); goto error; + } else { + /* 1 and 2 are the only expected values on success. */ + assert(size_data == 1); } set_default_uri_attr(&data_uris[0], LTTNG_STREAM_DATA); -- 2.34.1