Skip to contentSkip to conversation

client: Fix app params memory management

PATCH In review Bartosz Szatkowski 2 participants 2 messages Nov 21, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: Fix app params memory management

---
 client/transfer.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
client/transfer.c +6 -0
index b6994d1..b314926 100644
@@ -356,6 +356,12 @@ static void get_buf_xfer_progress(GObex *obex, GError *err, GObexPacket *rsp,
 	if (hdr) {
 		g_obex_header_get_bytes(hdr, &buf, &len);
 		if (len != 0) {
+			if (transfer->params == NULL)
+				transfer->params =
+					g_new0(struct obc_transfer_params, 1);
+			else if (transfer->params->data != NULL)
+				g_free(transfer->params->data);
+
 			transfer->params->data = g_memdup(buf, len);
 			transfer->params->size = len;
 		}
Signature · 1 line
1.7.4.1
#1 lore raw

Hi Bartosz,

Quoted 3 lines · Bartosz Szatkowski
---
 client/transfer.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Applied after a minor fix (you don't need to check for NULL before calling g_free). Thanks.

Johan