summaryrefslogtreecommitdiffstats
path: root/common/glib-helper.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-05-16 23:45:23 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2008-05-16 23:45:23 +0000
commitf475b6c9b0de7c06d64b5ba147ac770dbe88419d (patch)
tree15992614d56249f6ca3ecf67469c73bc29b6956f /common/glib-helper.c
parente9f3959fb8c5e4ac323410348013d7c7041146a7 (diff)
Fix bt_rfcomm_connect segfault
Diffstat (limited to 'common/glib-helper.c')
-rw-r--r--common/glib-helper.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index 59293334..0333ca07 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -740,7 +740,7 @@ static int rfcomm_bind(struct io_context *io_ctxt, const bdaddr_t *src,
int err;
io_ctxt->fd = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
- if ( io_ctxt->fd < 0)
+ if (io_ctxt->fd < 0)
return -errno;
if (flags) {
@@ -756,7 +756,7 @@ static int rfcomm_bind(struct io_context *io_ctxt, const bdaddr_t *src,
memset(addr, 0, sizeof(*addr));
addr->rc_family = AF_BLUETOOTH;
bacpy(&addr->rc_bdaddr, src);
- addr->rc_channel = *channel;
+ addr->rc_channel = channel ? *channel : 0;
err = bind(io_ctxt->fd, (struct sockaddr *) addr, sizeof(*addr));
if (err < 0) {
@@ -764,7 +764,8 @@ static int rfcomm_bind(struct io_context *io_ctxt, const bdaddr_t *src,
return -errno;
}
- *channel = addr->rc_channel;
+ if (channel)
+ *channel = addr->rc_channel;
return 0;
}
@@ -794,7 +795,7 @@ static int rfcomm_connect(struct io_context *io_ctxt, const bdaddr_t *src,
struct sockaddr_rc addr;
int err;
- err = rfcomm_bind(io_ctxt, src, 0, 0, &addr);
+ err = rfcomm_bind(io_ctxt, src, NULL, 0, &addr);
if (err < 0)
return err;