Skip to contentSkip to conversation

Fix leaks in plugin

PATCH In review Steve Grubb 1 participant 1 message May 14, 2021 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 3/6 Fix leaks in plugin

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(-)
plugins/hostname.c +1 -2
index f7ab9e8bc..1a9513adb 100644
@@ -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:
Signature · 1 line
2.31.1