gateway: Fix crash if SCO connection fails
PATCH 1/1 gateway: Fix crash if SCO connection fails
In some situations, a connect callback is created, but this callback is not added to media_owner. Thus when the owner is destroyed and at rfcomm disconnect, the callback is executed with an invalid pointer.
--- audio/gateway.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
audio/gateway.c +1 -4
@@ -836,12 +836,9 @@ unsigned int gateway_request_stream(struct audio_device *dev, gateway_stream_cb_t cb, void *user_data) { struct gateway *gw = dev->gateway; -unsigned int id;GError *err =NULL ;GIOChannel *io; - id =connect_cb_new (gw, cb, user_data); -if (!gw->rfcomm)get_records (dev);else if (!gw->sco) {
@@ -858,7 +855,7 @@ unsigned int gateway_request_stream(struct audio_device *dev, }else g_idle_add (request_stream_cb, dev); -return id; +return connect_cb_new (gw, cb, user_data); } int gateway_config_stream(struct audio_device *dev, gateway_stream_cb_t cb,
Signature · 1 line
1.7.5.4
Luiz Augusto von Dentz
maintainerHi Frédéric,
2012/2/7 Frédéric Dalleau <[email protected]>:
Quoted 35 lines
In some situations, a connect callback is created, but this callback is not added to
media_owner. Thus when the owner is destroyed and at rfcomm disconnect, the callback is executed with an invalid pointer.
---
audio/gateway.c | 5 +----1 files changed, 1 insertions(+), 4 deletions(-)audio/gateway.c +1
-5@@ -836,12 +836,9 @@ unsigned int gateway_request_stream(struct audio_device *dev, gateway_stream_cb_t cb, void *user_data) { struct gateway *gw = dev->gateway; - unsigned int id; GError *err = NULL; GIOChannel *io; - id = connect_cb_new(gw, cb, user_data); - if (!gw->rfcomm) get_records(dev); else if (!gw->sco) {@@ -858,7 +855,7 @@ unsigned int gateway_request_stream(struct audio_device *dev, } else g_idle_add(request_stream_cb, dev); - return id; + return connect_cb_new(gw, cb, user_data); } int gateway_config_stream(struct audio_device *dev, gateway_stream_cb_t cb, --
Quoted 1 line
1.7.5.4
It doesn't seems this change anything since the id is always returned anyway, have you tried to reproduce it while running with valgrind?
Signature · 1 line
Luiz Augusto von Dentz
Hi Luiz,
2012/2/7 Luiz Augusto von Dentz <[email protected]>
Quoted 3 lines
Hi Frédéric,
It doesn't seems this change anything since the id is always returned anyway, have you tried to reproduce it while running with valgrind?
There is one case where the function returns 0.
It doesn't appear in the patch, but you can check in the code. However I haven't tested with valgrind.
Regards,
Frédéric