fix glib CRITICAL warning

In the case when we deal with the timeout/error result, the resource
has lready been unref

Signed-off-by: vlefebvre <valentin.lefebvre@iot.bzh>
github-action
vlefebvre 2021-05-26 14:35:42 +02:00 committed by Olivier Martin
parent f3b5b295bc
commit d66e268865
1 changed files with 3 additions and 2 deletions

View File

@ -417,8 +417,9 @@ static gatt_connection_t *gattlib_connect_with_options(const char *src, const ch
while ((io_connect_arg.connected == FALSE) && (io_connect_arg.timeout == FALSE)) {
g_main_context_iteration(g_gattlib_thread.loop_context, FALSE);
}
// Disconnect the timeout source
g_source_destroy(timeout);
// Disconnect the timeout source if connection success
if (io_connect_arg.connected) g_source_destroy(timeout);
if (io_connect_arg.timeout) {
return NULL;