[PATCH obexd 1/6] client: fix memory leak in obc_session_put

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

 



From: Mikel Astiz <mikel.astiz@xxxxxxxxxxxx>

obc_session_put takes ownership of the given buffer, but did not free
the memory in case of error.
---
 client/session.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/client/session.c b/client/session.c
index 585e402..cb46510 100644
--- a/client/session.c
+++ b/client/session.c
@@ -1007,8 +1007,10 @@ int obc_session_put(struct obc_session *session, char *buf, const char *targetna
 	struct obc_transfer *transfer;
 	const char *agent;
 
-	if (session->obex == NULL)
+	if (session->obex == NULL) {
+		g_free(buf);
 		return -ENOTCONN;
+	}
 
 	agent = obc_agent_get_name(session->agent);
 
@@ -1016,8 +1018,10 @@ int obc_session_put(struct obc_session *session, char *buf, const char *targetna
 							agent, NULL,
 							targetname, NULL,
 							NULL);
-	if (transfer == NULL)
+	if (transfer == NULL) {
+		g_free(buf);
 		return -EIO;
+	}
 
 	obc_transfer_set_buffer(transfer, buf);
 
-- 
1.7.6.5

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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