[PATCH BlueZ] attrib: Fix crash if g_attrib_new() fails

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

 



If g_attrib_new() fails for some reason (e.g. bt_io_get() fails), it
will return NULL.

Crash reported by Valgrind:

==2845== Invalid read of size 4
==2845==    at 0x40C6CC4: g_io_channel_unix_get_fd (giounix.c:655)
==2845==  Address 0x3c is not stack'd, malloc'd or (recently) free'd
---
 src/attrib-server.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/attrib-server.c b/src/attrib-server.c
index 3b94120..61395a5 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -1235,6 +1235,9 @@ static void connect_event(GIOChannel *io, GError *gerr, void *user_data)
 	}
 
 	attrib = g_attrib_new(io);
+	if (!attrib)
+		return;
+
 	attrib_channel_attach(attrib);
 	g_attrib_unref(attrib);
 }
-- 
1.7.9.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