[PATCH BlueZ v1] media: fix memory leak in endpoint_init_pac()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



asprintf() allocates memory in the name variable but does not
free it before exiting the function, which causes a memory leak.

Add freeing of the name variable before exiting.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
---
 profiles/audio/media.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index b5644736a..746e538fc 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -1280,6 +1280,7 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type,
 	if (asprintf(&name, "%s:%s", endpoint->sender, endpoint->path) < 0) {
 		error("Could not allocate name for pac %s:%s",
 				endpoint->sender, endpoint->path);
+		free(name);
 		return false;
 	}
 
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux