Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 2/2] client: Address dbl free reported by coverity
Date: Tue, 15 Oct 2019 10:34:12 -0700	[thread overview]
Message-ID: <20191015173412.11810-2-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20191015173412.11810-1-tim.a.kourt@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]

In practice, the double free isn't possible in this logic.

It also simplifies the print logic
---
 client/station.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/client/station.c b/client/station.c
index a332f486..a89c9833 100644
--- a/client/station.c
+++ b/client/station.c
@@ -338,7 +338,6 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
 {
 	char *dbms = NULL;
 	const struct l_queue_entry *entry;
-	bool is_first;
 
 	display_table_header("Available networks", "%s%-*s%-*s%-*s%*s",
 					MARGIN, 2, "", 32, "Network name",
@@ -351,7 +350,7 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
 		return;
 	}
 
-	for (is_first = true, entry = l_queue_get_entries(ordered_networks);
+	for (entry = l_queue_get_entries(ordered_networks);
 						entry; entry = entry->next) {
 		struct ordered_network *network = entry->data;
 		const struct proxy_interface *network_i =
@@ -362,24 +361,17 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
 		if (display_signal_as_dbms)
 			dbms = l_strdup_printf("%d", network->signal_strength);
 
-		if (is_first && network_is_connected(network_i)) {
-			display("%s%-*s%-*s%-*s%-*s\n", MARGIN,
-				2, COLOR_BOLDGRAY "> " COLOR_OFF,
-				32, network_name, 10, network_type,
-				6, display_signal_as_dbms ? dbms :
-					dbms_tostars(network->signal_strength));
+		display("%s%-*s%-*s%-*s%-*s\n", MARGIN, 2,
+			network_is_connected(network_i) ?
+				COLOR_BOLDGRAY "> " COLOR_OFF : "",
+			32, network_name, 10, network_type,
+			6, display_signal_as_dbms ? dbms :
+				dbms_tostars(network->signal_strength));
 
+		if (display_signal_as_dbms) {
 			l_free(dbms);
-			is_first = false;
-			continue;
+			dbms = NULL;
 		}
-
-		display("%s%-*s%-*s%-*s%-*s\n", MARGIN, 2, "",
-				32, network_name, 10, network_type,
-				6, display_signal_as_dbms ? dbms :
-					dbms_tostars(network->signal_strength));
-
-		l_free(dbms);
 	}
 
 	display_table_footer();
-- 
2.13.6

  reply	other threads:[~2019-10-15 17:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-15 17:34 [PATCH 1/2] eap-ttls: Address mem leak reported by coverity Tim Kourt
2019-10-15 17:34 ` Tim Kourt [this message]
2019-10-16 20:50 ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191015173412.11810-2-tim.a.kourt@linux.intel.com \
    --to=tim.a.kourt@linux.intel.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox