Thread (2 messages) 2 messages, 2 authors, 2014-01-24

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

flat view
STALE4638d

From: Anderson Lizardo <hidden>
Date: 2014-01-24 19:57:49
Subsystem: the rest · Maintainer: Linus Torvalds

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help