diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c
index 134d157..d672670 100644
--- a/profiles/audio/sink.c
+++ b/profiles/audio/sink.c
sink->connect_id = a2dp_discover(sink->session, discovery_complete,
sink);
- if (sink->connect_id == 0)
+ if (sink->connect_id == 0) {
+ avdtp_unref(sink->session);
+ sink->session = NULL;
return FALSE;
+ }
return TRUE;
}
diff --git a/profiles/audio/source.c b/profiles/audio/source.c
index fca85d4..c706c92 100644
--- a/profiles/audio/source.c
+++ b/profiles/audio/source.c
source->connect_id = a2dp_discover(source->session, discovery_complete,
source);
- if (source->connect_id == 0)
+ if (source->connect_id == 0) {
+ avdtp_unref(source->session);
+ source->session = NULL;
return FALSE;
+ }
return TRUE;
}