linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez PATCH 3/6] Fix leaks in plugin
@ 2021-05-12 21:37 Steve Grubb
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Grubb @ 2021-05-12 21:37 UTC (permalink / raw)
  To: linux-bluetooth


g_file_get_contents allocates memory. It needs to be freed on any
function exit.

Signed-off-by: Steve Grubb <sgrubb@redhat.com>
---
 plugins/hostname.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/hostname.c b/plugins/hostname.c
index f7ab9e8bc..1a9513adb 100644
--- a/plugins/hostname.c
+++ b/plugins/hostname.c
@@ -213,11 +213,10 @@ static void read_dmi_fallback(void)
 		return;
 
 	type = atoi(contents);
+	g_free(contents);
 	if (type < 0 || type > 0x1D)
 		return;
 
-	g_free(contents);
-
 	/* from systemd hostname chassis list */
 	switch (type) {
 	case 0x3:
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread
* [Bluez PATCH 3/6] Fix leaks in plugin
@ 2021-05-14 13:59 Steve Grubb
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Grubb @ 2021-05-14 13:59 UTC (permalink / raw)
  To: linux-bluetooth


g_file_get_contents allocates memory. It needs to be freed on any
function exit.

---
 plugins/hostname.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/plugins/hostname.c b/plugins/hostname.c
index f7ab9e8bc..1a9513adb 100644
--- a/plugins/hostname.c
+++ b/plugins/hostname.c
@@ -213,11 +213,10 @@ static void read_dmi_fallback(void)
 		return;
 
 	type = atoi(contents);
+	g_free(contents);
 	if (type < 0 || type > 0x1D)
 		return;
 
-	g_free(contents);
-
 	/* from systemd hostname chassis list */
 	switch (type) {
 	case 0x3:
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-14 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-12 21:37 [Bluez PATCH 3/6] Fix leaks in plugin Steve Grubb
  -- strict thread matches above, loose matches on Subject: below --
2021-05-14 13:59 Steve Grubb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).