summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-07 13:00:13 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-07 13:00:13 +0000
commit8b415b792063dc548c753c37166dfa104157daee (patch)
treeda32e111340b3c4cf200472a3decb13ca339673e /common
parent7e31dd1071053dd326f19633a6f64188c787326d (diff)
glib-helper: use g_try_malloc instead of g_malloc
Diffstat (limited to 'common')
-rw-r--r--common/glib-helper.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c
index f4d3f9d4..5938e654 100644
--- a/common/glib-helper.c
+++ b/common/glib-helper.c
@@ -154,11 +154,13 @@ int bt_discover_services(const bdaddr_t *src, const bdaddr_t *dst,
s = sdp_connect(src, dst, SDP_NON_BLOCKING);
if (!s)
- return -EIO;
+ return -errno;
- ctxt = g_malloc0(sizeof(struct search_context));
- if (!ctxt)
+ ctxt = g_try_malloc0(sizeof(struct search_context));
+ if (!ctxt) {
+ sdp_close(s);
return -ENOMEM;
+ }
bacpy(&ctxt->src, src);
bacpy(&ctxt->dst, dst);